473,836 Members | 2,150 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 28007
Hi,

Have you tried impersonation?

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

"hiram" <oy*****@earthl ink.net> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.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 FileIOPermissio n(FileIOPermiss ionAccess.AllAc cess,
strPath)
fp.Assert()
IO.Directory.Cr eateDirectory(s trSubDirectory)
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
FileIOPermissio nAccess 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
3518
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 "C:\WINNT\system32"), while files in a folder are given the correct dir. To fix this I created a file that's included to all the files from php.ini
7
2556
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 w2k pro machine with anonymous access. Fyg this is non commercial website for neighbour members in a carpool with booking possibility. No file upload is allowed/possible/needed. Login is manged by the ASP script
0
1043
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 server side web service must have write permission on this sub folder. That is because, the server side web service will create documents in ths "Private Documents" folder, read it into a memory stream and will then delete the document. This...
2
2340
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 folder's NTFS permissions WITHOUT using WMI or special XP features? Thanks ahead! --Ram
4
2700
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 and granting read/write access to a specific user {not the user running the program}. Any ideas? Or am I going to have to PInvoke like crazy??
0
865
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. However, I'm not able to write temporary files to a "temp" directory on the hosting account. Their technical support tells me that this is because when Front Page Extensions are set, they take control over file permissions. To override this...
4
3097
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
4122
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 permissions for this folder is set to 777. I have set up a page in the package to call a .PHP page. When I try to run the PHP page I get the error message: "A file permissions error has occurred running this script.
0
840
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 fails for whatever reason, I need to go back and delete the file from the folder where the write was successful. To complicate things, the file that was written successfully might already by moved by a secondary process of which I have no control...
2
3127
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 registered users should have access to. For that I've set only Write permission in the IIS for that folder which enables any user to upload the resume but also disabling the registered user to access. The registered users will be stored in SQL Server...
0
9810
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
10821
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
10527
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...
1
10573
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10241
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
5642
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...
0
5812
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4443
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 we have to send another system
3
3102
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.