Click here to Skip to main content
15,881,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,


Sorry to respectable sir/mam because i put my last question absolutely in wrong manner now i am going to mention some details

i write the following code for the file searching in my anti virus and it give exception when it scan "system volume information " folder
please help me by editing this code that it also give me the list of all files in "system volume information" folder

code is:

I am using c# language
***********************************************************************
C#
//get the drive names on the target computer
            DriveInfo[] drives = DriveInfo.GetDrives();
            foreach (DriveInfo drive in drives)
            {
                //Console.WriteLine("Drive: {0} {1}", drive.Name, drive.DriveType);
                comboBox2.Items.Add(drive.Name);
                if (drive.DriveType.ToString() == "Fixed")
                {
                    try
                    {
                        //Search for the folder in each drive
                        string[] dirs = //Directory.GetDirectories(drive.Name, "MySql", SearchOption.AllDirectories);
                        Directory.GetDirectories(drive.Name,"*.*",SearchOption.AllDirectories);
                        comboBox1.Items.Add(dirs.Length);
                        foreach (string dir in dirs)
                        {
                            comboBox1.Items.Add(dir);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
            }





*********************************************************************** The exception i am getting is as fellow i just mention below:

"System.UnauthorizedAccessException:Access to the path 'c:\System Volume Information'is denied.at system.IO.__Error.winIoeRROR(Int32 errorCode,string maybeFullpath)
at system.IO.InternalGetFileDirectioryName(string path,string userpathoriginal,string searchpattern,booleanincludeFiles,boolean includeDirs,Searchopyion searchoption)
at system.IO.Directiory.GetDirectories(string path,string searchpattern,searchoption searchoption)
at Antivirius.Form1.Form1_load)object Sender,EventArgs e)in D:\Documents and Settings\Shafiq Ur Rehman\My Documents\Visual Studio 2008\projects\Antivirius\Antivirius\Form1.cs:line34 "
Posted
Updated 18-Apr-10 3:43am
v4

System Volume information access is blocked by default. Normally only the system can access this. You could give yourself access, but it's generally not a good idea. You should not mess around with what's in there (shadow copies, for instance).
Note that if you're writing some anti-virus software, you're tackling this the wrong way. Get yourself a copy of the DDK, and implement your scanning software as a filter driver. (filter drivers are part of the system, and they can access all files. No C# allowed though :-) )
On second thoughts, don't: If you can't figure out UnauthorizedAccessException means you don't have access, you'll probably destroy your system within half an hour of downloading the DDK.
 
Share this answer
 
You have to tell us what exception you're getting. We can't just divine this info from the code you posted.
 
Share this answer
 
Comments
The Magical Magikarp 11-Jan-20 19:37pm    
This is not an answer.
#realJSOP 12-Jan-20 5:24am    
Uou do realize this question is 10 years old, right?
The Magical Magikarp 8-Feb-20 20:27pm    
Yes, I laughed after I posted the comment :)
ssp_shafiq wrote:
am waiting for your kind reply

Don't ask the same question twice, please :)
 
Share this answer
 
You can jump from the "System Volume Information" folder using if condition.

1.Get all folders in the top of the drive as a list.
2.Get files exept System... Directory

string[] directories = Directory.GetDirectories(@"e:\","*",SearchOption.TopDirectoryOnly);

foreach(string directory in directories)
{

If(directory != @"e:/System Volume Information")


string[] sub_files = Directory.GetFiles(directory, "*.*", SearchOption.TopDirectoryOnly);

foreach(string sub_file in sub_files)
{
Listbox.items.add(sub_file);
}
}
 
Share this answer
 
Comments
Richard MacCutchan 4-Jan-16 6:36am    
This question is nealy six tears old, your post is far too late for the OP.
The Magical Magikarp 11-Jan-20 19:38pm    
That's fine -- Someone may come looking for the answer and find this post :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900