Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / June 2007

Tip: Looking for answers? Try searching our database.

File And Directory Rights

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jehugaleahsa@gmail.com - 28 Jun 2007 05:05 GMT
Hello:

I have been looking online trying to find a simple way to find file/
directory rights in C#.

I have been seeing a lot of options, none of which are obvious. I am
looking for something like this:

bool CanRead(string path) . . . // would be willing to write this
myself

If you can help me get started, that would be great. And if possible,
can we ignore any Microsoft.Win32 libraries? I want to stick to
System.* libraries.

Thanks muches!

~Travis
Peter Duniho - 28 Jun 2007 05:11 GMT
> I have been looking online trying to find a simple way to find file/
> directory rights in C#.

Does this help?

http://msdn2.microsoft.com/en-us/library/ms229742.aspx

And more specifically:
http://msdn2.microsoft.com/en-us/library/system.io.file.getaccesscontrol.aspx
http://msdn2.microsoft.com/en-us/library/system.io.directory.getaccesscontrol.aspx

If not, maybe you can be more specific about what "rights" it is you're  
trying to determine.

Pete
jehugaleahsa@gmail.com - 28 Jun 2007 13:54 GMT
> And more specifically:http://msdn2.microsoft.com/en-us/library/system.io.file.getaccesscont...http://m
sdn2.microsoft.com/en-us/library/system.io.directory.getacces
...

These are the classes I was looking at yesterday. Could you give an
example that just checks if an application can read a directory? I
have no idea how to use these methods.

Thanks!
Peter Duniho - 28 Jun 2007 18:06 GMT
> These are the classes I was looking at yesterday. Could you give an
> example that just checks if an application can read a directory? I
> have no idea how to use these methods.

It's not the application that can or cannot read a directory, it's the  
user.

I admit, I haven't used the .NET ACL stuff.  But I believe it's what you  
want.  You need to cross-reference the ACL retrieved for a file system  
object with the current user and their rights, which should tell you the  
theoretical rights you have for the object.

How to do this specifically, I don't know.  But the ACL is where that  
information is stored, so that's where I believe you need to start looking.

Pete

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.