473,473 Members | 2,097 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

File And Directory Rights

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

Jun 28 '07 #1
3 1794
On Wed, 27 Jun 2007 21:05:46 -0700, je**********@gmail.com
<je**********@gmail.comwrote:
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/lib...sscontrol.aspx
http://msdn2.microsoft.com/en-us/lib...sscontrol.aspx

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

Pete
Jun 28 '07 #2
And more specifically:http://msdn2.microsoft.com/en-us/lib...ctory.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!

Jun 28 '07 #3
On Thu, 28 Jun 2007 05:54:55 -0700, je**********@gmail.com
<je**********@gmail.comwrote:
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
Jun 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Leo | last post by:
Hi I had asekd previously a question qith regards to running a DLL file from ASP. It was not running for me. Bo error returned, nothing, Just an empty string (when it should have not been...
18
by: Dan | last post by:
I have code like the following to test for existence of a file. I know the file is there, but File.Exists returns FALSE. The problem appears to be that the file is in a directory beneath "My...
12
by: Mark | last post by:
Hello, in a simple console application I try to create a file with some code like: FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate, FileAccess.Write); StreamWriter sw = new...
6
by: Thomas Connolly | last post by:
I have 2 pages referencing the same codebehind file in my project. Originally the pages referenced separate code behind files. Once I changed the reference to the same file, everything worked...
6
by: Chad Crowder | last post by:
Getting the following error on my production server whether the file exists or not: "System.IO.IOException: Cannot create a file when that file already exists." Here's the code generating the...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
4
by: Stephane | last post by:
Hi, Is there any way we can access a file using the physical path on a remote server? I need to read and delete content of a remote directory on the LAN. All I got so far is access denied so I...
3
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
15
by: David Thielen | last post by:
Hi; My ASP.NET app (C# calling J# under .net 2.0) creates a png file in a subdirectory to display as part of the created page. However, the bitmap will not display due to a security violation. ...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I cut and paste the following code from msdn help page which it just introduces view and multiview server controls. Here is what I do: in vs studio 2005, File --New Web Site, it...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.