hi
i try to list all file of certain type from my c drive. but i run into the same problem every time
(Access to the path 'C:\$Recycle.Bin\S-1-5-18' is denied.)
how can i work around this problem.
my code is the following:
private void button1_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
var files = Directory.EnumerateFiles(@"C:\", "*" + comboBox1.SelectedItem.ToString(), SearchOption.AllDirectories);
foreach (string file in files)
{
string filename = Path.GetFileNameWithoutExtension(file);
ListViewItem item = new ListViewItem(filename);
item.Tag = file;
listView1.Items.Add(item);
}
}
Loading
Abhay ShankerPosted May 18, 2014, 11:10 PM
How to start a Process as administrator mode in C#
http://stackoverflow.com/questions/2532769/how-to-start-a-process-as-administrator-mode-in-c-sharp
VulpesPosted May 18, 2014, 3:07 PM
What I've tried to do with the above code is to catch and simply 'swallow' this exception so that the iteration can continue with the next directory and the user won't be any the wiser.
Note that even if this code runs, it may take a long time to execute depending on the number of directories and files on your system.
kevin bredahlPosted May 18, 2014, 2:28 PM
VulpesPosted May 18, 2014, 2:07 PM
kevin bredahlPosted May 18, 2014, 12:47 PM
can i make some kind for exception for the recyclebin
VulpesPosted May 18, 2014, 12:40 PM
However, before you think about doing stuff like that, I'd see whether that's actually the problem.
kevin bredahlPosted May 18, 2014, 12:28 PM
VulpesPosted May 18, 2014, 12:21 PM