Directory access

  • Thread starter Thread starter Bit Twiddler
  • Start date Start date
B

Bit Twiddler

Hi,

What is the *proper* way to determine if I have write-access to a given
directory?

Thanks!
BT
 
Bit said:
Hi,

What is the proper way to determine if I have write-access to a given
directory?

Get first a DirectoryInfo object using:
DirectoryInfo di = new DirectoryInfo(@"c:\MyDir");

then, call di.GetAccessControl() (or the overload).

FB

--
 
DirectoryInfo.GetAccessControl() returns a DirectorySecurity object:

DirectoryInfo di = new DirectoryInfo(@"c:\MyDir");
DirectorySecurity ds = di.GetAccessControl();

Now I can call ds.AccessRightType, but I don't understand why this returns a
Type, instead of a mask representing the FileSystemRights enumeration.

If I could get those flags I could just check for
FileSystemRights.CreateFiles, etc.

Any pointers would be appreciated!

Thanks,
BT
 
Back
Top