473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Folder permissions in .NET

I have a folder on a local machine that has the access security
settings set in Windows so that only the administrator can perform
write or create operations on the folder. Everyone else is given read
only access to the folder.
I am trying to write a vb.net program that can create and modify files
and folders in the above mentioned folder. I am running into problems
with access permissions when I try to create a new sub-directory in the

folder because the users running the program do not have access to the
folder. I would like to give the vb.net program full and unrestricted
access to the folder without having to give the user that runs the
program the same access. Does anyone know how to do this in vb.net? I
can't have an administrator password box pop up in the program because
the users don't have the administrator password and I don't want them
to.

Nov 21 '05 #1
5 27880
Hi,

Have you tried impersonation?

http://www.dotnet247.com/247referenc...28/144136.aspx
FileIOPermission
http://msdn.microsoft.com/library/de...sctorTopic.asp
Ken
--------------

"hiram" <oy*****@earthlink.net> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I have a folder on a local machine that has the access security
settings set in Windows so that only the administrator can perform
write or create operations on the folder. Everyone else is given read
only access to the folder.
I am trying to write a vb.net program that can create and modify files
and folders in the above mentioned folder. I am running into problems
with access permissions when I try to create a new sub-directory in the

folder because the users running the program do not have access to the
folder. I would like to give the vb.net program full and unrestricted
access to the folder without having to give the user that runs the
program the same access. Does anyone know how to do this in vb.net? I
can't have an administrator password box pop up in the program because
the users don't have the administrator password and I don't want them
to.
Nov 21 '05 #2
Try this:

Imports System.Security.Permissions

Dim strPath As String = "C:\MyPath"
Dim strSubDirectory As String = IO.Path.Combine(strPath,
"MySubDirectory")

Dim fp As New FileIOPermission(FileIOPermissionAccess.AllAccess,
strPath)
fp.Assert()
IO.Directory.CreateDirectory(strSubDirectory)
fp.RevertAssert()
fp = Nothing

Add the Dim fp... behind a button...

I hope this helps

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #3
Thanks Ken,
The impersonation code at www.dotnet247.com solved the problem.

Nov 21 '05 #4
This code did not work for this problem. I had found this code on msdn
before during my search. I am not exactly sure what the
FileIOPermissionAccess class does. I do know that it will not allow me
to access a directory that I don't already have permissions on.

Thanks for the suggestion.

Nov 21 '05 #5
Its always worked for me in the situation you described. Yes, of course
impersonating the administrator is used to, but in my experience I've seen
it used more in web applications rather than Windows progs.

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #6

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

Similar topics

0
by: Andrew Crowe | last post by:
Hi guys, We're using the ISAPI version of PHP with IIS5.0 On some websites for some reason any php file in the websites root is given the path winnt/system32 (getcwd() returns...
7
by: Kim Lots | last post by:
Hi Sorry to disturb you again but i really like to know what's the NTFS folder permissions on a "virtual directory" folder for a public webserver iis 5.x running ASP 3.0 with an Access DB on a...
0
by: Srilatha | last post by:
Hi, I have a folder called "Public_Documents" on my web server. The documents in this folder should be accessible to everyone. I want to create a sub folder here "Private Documents". Only the...
2
by: Ram | last post by:
Hey, I'v managed to find a way of adding NTFS permissions to a certain folder, But the problem is, the folder has a couple of inherited permissions which I want to delete. How can I remove the...
4
by: Richard | last post by:
Hi all, Is there any class in .NET 1.x that will help me set file & folder permissions for a user? Aka - I would like to do the in code equivalent of right clicking a folder in file explorer...
0
by: Tom C. | last post by:
Does anyone know how to set Customer Folder Permissions in Visual Studio? I have Front Page Extensions set on our hosting provider so that I can use the Project - Copy Project feature of VS. ...
4
by: Joey | last post by:
Hey, How can I add/edit/delete Folder NTFS permissions in .NET? I have a Win2K Box, and WMI is not installed on my servers Thanks ahead! -- Joey
2
by: skinnybloke | last post by:
Hi - I have a file permissions problem with PHP. I am using a product called Actinic to develop a shopping cart. This creates a subfolder named ACATALOG into which it loads all of its files. The...
0
by: Mark | last post by:
Is there a way to determine what folder permissions I have before trying to write a file to it? My dilema is that I have to write a file to two folders (on different machines). If one write...
2
by: harrish | last post by:
Can we set folder permissions in IIS 5 through ASP 2.0 coding? In my case, there is a particular folder named "Resumes" in the website in which anonymous users can post their profile but only...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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...
0
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...
0
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...
0
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,...

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.