Checking Directory Permission or Try catch?

advapi

New member
Joined
Aug 30, 2006
Messages
1
Hello,
Im tring to write a simple application that scans hard drive contents to find some files... Im getting stucked with a particular directory ( C:\System Volume Information).
As soon as I try to do
Code:
directory.GetDirectories()
I receive an UnAuthorizedException.

Is there a way to check permission before trying to access to the directory?
For now Ive got around using try{}catch{} and creating a new FileSystemInfo[] ( I start from FileSystemInfo then I check if its a dir/file using
Code:
is DirectoryInfo/FileInfo
).

Am I right or theres a better way?

Thanks
 
Check Directory Attributes

Hi, try checking the attributes of the folders you get in scanning your directories. You can do so by creating instances of DirectoryInfo class for each path that you get. If i remember right, the directory you are trying to access is a system folder. and well, corresponding privileges apply to certain users. you can read on access permissions. MSDN library is an indespensable source for such information.



Thanks
 
Back
Top