How to find Folder permissions and existance?

Hello,

I was wondering what to use when trying to find the existance and permissions of a certain folder with a given path. When I say permissions I mean whether or not I am allowed to create a new file in that location, or edit a file in that location. For existance, I have found the .Exists method, but is this the best way to do so

Thanks,

Tareq Ismail



Answer this question

How to find Folder permissions and existance?

  • matt01

    Hi,

    Thanks, that information has helped. I now know how to find out if the folder exists, but I still cannot figure out how to find if it has the correct permissions. The link you sent showed me how to change it but how to determine if I can write to it.

    I am on a machine that has certain folders disabled for editing ( for example Program Files\) because I do not have administrator privledges. I am writing a peice of software that will modify a file in a certain way at a certain path. I just want to make sure that the path given I can actually write to and that it exists.

    Can anyone help

    Thanks again guy kolbis,

    Tareq Ismail


  • Drew Marsh

    Hi,

    You can use the Directory class or the DirectoryInfo class.

    Both will let you manipulate the directory.

    Regarding the Permissions.. Follow this link:

    http://weblogs.asp.net/cumpsd/archive/2004/02/08/69403.aspx

    I hope this help..

    guy kolbis



  • Mark Flamer

    Hi,

    try this link:

    http://www.gotdotnet.com/Community/UserSamples/Details.aspx SampleGuid=e6098575-dda0-48b8-9abf-e0705af065d9

    This is a C# library containing wrapper classes for ACL, ACE, Security descriptors, Security Attributes, Access tokens, etc. The archive also contains 3 samples: A "Task manager" WinForms application that uses the library to display token information of running processes and threads. A command line version of the same application. And finally, a demo application displaying the DACL of the "C:\boot.ini" file and creating a Win32 Event object with a security descriptor built using the library classes.



  • How to find Folder permissions and existance?