How do I get directory permissions?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,

i am reading the directory structure into a treeview. when i select a new
drive and do not have access to an existing folder; i get an acess denied -
System.UnauthorizedAccessException error. how would i check for that in the
code.

i have tried this below, but i still get the error. any help ?
If Directory.GetDirectories(subDir).IsReadOnly = True Then
'do nothing
Else
If Directory.GetDirectories(subDir).Length <> 0
Then
subNode.Nodes.Add("")
End If

End If
 
Hi Lee,

try this.

DirectoryInfo [] subdir=null;
try
{
subdir=Directory.GetDirectories(subDir);
}
catch(Exception ex)
{
//handle exception
}
if(subdir!=null)
{
//iterate thru subdirectories array.
}
 
Back
Top