System.UnauthorizedAccessException

Lada_Karford

Newcomer
Joined
Feb 24, 2010
Visual Basic:
Dim DirInfo As IO.DirectoryInfo = DriveInfo.RootDirectory
If I get into a protected system folder like "System Volume Information" in the root of drive, I get System.UnauthorizedAccessException.
So how can I check DirInfo to prevent this exception?
Thanks.
 

PlausiblyDamp

Administrator
Joined
Sep 4, 2002
Location
Lancashire, UK
Most of the system protected folders are marked as both hidden and system - it might be worth checking these attributes before attempting to access the folder. Alternatively you could just wrap the access in a try...catch block and handle the UnauthorizedAccessException when it occurs.
 
Top Bottom