473,729 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Directory access

Hi,

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

Thanks!
BT
Dec 26 '05 #1
2 5109
Bit Twiddler wrote:
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.GetAccessCon trol() (or the overload).

FB

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Dec 27 '05 #2
DirectoryInfo.G etAccessControl () returns a DirectorySecuri ty object:

DirectoryInfo di = new DirectoryInfo(@ "c:\MyDir") ;
DirectorySecuri ty ds = di.GetAccessCon trol();

Now I can call ds.AccessRightT ype, but I don't understand why this returns a
Type, instead of a mask representing the FileSystemRight s enumeration.

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

Any pointers would be appreciated!

Thanks,
BT
"Frans Bouma [C# MVP]" <pe************ ******@xs4all.n l> wrote in message
news:xn******** *******@news.mi crosoft.com...
Bit Twiddler wrote:
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.GetAccessCon trol() (or the overload).

FB

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

Dec 27 '05 #3

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

Similar topics

0
777
by: Tom Youngquist | last post by:
I have two .NET sits (one is intranet and one internet). One of the "subdirectories" in the internet site I would like to include in my intranet site. I have created a "vertual directory" through the IIS manager on the intranet site to this directory (stored on a separate machine accesable from the first) but can not seem to figure out how to get that directory included in my intranet project. It does not appear even though I have...
2
3407
by: Jamie Bissett | last post by:
I cannot find ant doc to indicate how to access the user selected installation directory during the install process. I am trying to update the application confiduration file based upon some of the responses from the user during installation. Thanks in advance Jamie
2
4393
by: Annette Massie | last post by:
Is there a way to find the names of users in an Active Directory WWW group?
0
1172
by: Dominic | last post by:
I got the following error when I built a project. vcdeploy : error VCD0035: Failed to create the file system directory for the virtual directory. Access is denied. The project / properties / Web Deployment is set such that it should create a virtual directory. However, it returned the above error. I suspect that I need to set permission of some objects, but I don't know what to set?
1
1231
by: Len Svitenko | last post by:
I have a site in asp.net. In that site I have a directory full of excel spreadsheets. When a user logs in it points them to the spreadsheet that I want them to see. However, if they then exit out and go directly to the link it still re-opens the spreadsheet. Here's what I am asking. How can I setup the spreadsheets/directory so that you have to have logged in for the server to allow you into the directory. Here's the geek speak:
2
1314
by: Hari | last post by:
Hi I have an ASP.NET application that writes to a log file in a directory outside the webapp directory (e.g. c:\program files\myapp\logs). OS is Windows 2003 If I see the list of users in the "Security" tab for the 'logs' directory, I see that <localmachine>\Users already exists. Now, <localmachine>\ASPNET is a part of this 'Users' group. But this group does not have write access to the 'logs' directory. I think this is the default setting...
2
2211
by: web02 | last post by:
Hi y'all, It has been a long time and suddenly, I have a VC98 compiler with which I need to determine all the files in a directory and its subdirectories. I forget the functions available for doing this. I keep tripping over .NET in WEB searches. Can anyone provide me with a list of the functions to perform this. Thanx, Bill
2
1626
by: mark babli | last post by:
how can I access a remote (linux) directory using php?
0
1264
by: eholz1 | last post by:
Hello PHP group, I have a question about file locations, and whether on not (in my case, not) a page will execute depending on the location of the php file. I have a web devel server, with a directory below htdocs (using Apache 2.2 on Fedora Linux) /usr/local/apache2/htdocs/portfolios and /usr/local/apache2/htdocs/ portfolios/setup
1
1854
by: jyohere | last post by:
How to access a remote machine directory from a local machine....I tried something like this: opendir(DIR,"192.168.9.62:/home/cygnet/Marconi_PM_Simulator/conf/"); @files = readdir(DIR); closedir(DIR); 192.168.9.62 is the remote machine.....how can i do this..pls help me...
0
8763
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9428
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9285
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9151
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8155
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4529
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2686
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2165
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.