I am currently creating an application which searches through a directory and all its subdirectories for a certain file type and then if found displays this file type in a listbox.
heres my problem however, there are certain directories/subdirectories which i do not have access to so when i run my application i get an UnauthorizedAccessException and so the application fails to complete the search, i was wondering if there was a way i could ignore this exception and just continue the search with the next directory.
I would be very grateful for any help as i have been stuck for a while with no help, and i would appreciate some useful sample code if possible...here is the code i have at the moment....
private void button1_Click(object sender, EventArgs e)
{
try
{
listBox1.Items.Clear();
string[] temp = Directory.GetFiles(@"C:\", "*.drl", SearchOption.AllDirectories);
for (int i = 0; i < temp.Length; i++)
{
listBox1.Items.Add(temp[i]);
}
}
catch (UnauthorizedAccessException)
{
throw;
}
}