473,507 Members | 11,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do create a directory in under Programs in C#?

103 New Member
Hello,
I am trying to create a directory in my application but am recieving the System.UnauthorizedAccessException. Here is the lines of code that I am using, but I am not doing something right here. Can you provide me with help?

Expand|Select|Wrap|Line Numbers
  1. DirectorySecurity access = Directory.GetAccessControl(System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
  2.                 access.AddAccessRule(new FileSystemAccessRule(WindowsIdentity.GetCurrent().User, FileSystemRights.CreateDirectories, AccessControlType.Allow));
  3.                 string StudentTracker = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles, Environment.SpecialFolderOption.Create), "StudentTracker");
  4.                 Directory.CreateDirectory(StudentTracker, access);
  5.  
Dec 27 '13 #1
0 1023

Sign in to post your reply or Sign up for a free account.

Similar topics

5
3328
by: Ken Fine | last post by:
I want my application to maintain a directory tree based on months and years, e.g.: 2004 January file file file February file
0
1441
by: Alf P. Steinbach | last post by:
The seventh part of my attempted Correct C++ tutorial is now available, although for now only in Word format (use free Open Office if no Word), and also, it's not yet been reviewed at all -- ...
0
1545
by: richard.warner | last post by:
When you run 'aspnet_regiis -c', the aspnet_client directory is created under EVERY web site on the IIS server. It seems strange that there doesn't seem to be any way of running the command so...
2
2187
by: Paul Bromley | last post by:
How can I create a directory within a shared ntwork directory?? sServerName - is the Server name "\Docs" - is the shared directory "\Others" - is the directory to create. The following...
9
1767
by: André | last post by:
Hi, Is it possible to create directories and files with asp.net? Thanks André
5
1232
by: AmitGujrathi | last post by:
Hi all,,, can anybody pls tell me how to create directory on web server using C#.Net windows application thanks in Advance Amit
3
2248
by: Aneesh Pulukkul[MCSD.Net] | last post by:
I have a asp.net website and i need to create directories in the website. Basic requirement is to copy set of files to website(rather webserver machine) .These files are being referred in the web...
4
2809
by: Robert | last post by:
Greetings New to Visual Studio 2008. Always us VB6.0 SP5. I am trying to copy files from A to B. I select a directory, and copy files. Works ok, but it does not create the directory first. ...
4
1418
by: kathy30 | last post by:
I'm storing files in SQL and retrieving them when needed to the user's C: Drive This is accessed on our Intranet site, the problem is the create directory and saving files happens on the Server...
6
15191
by: coolestavi007 | last post by:
Hi, I have to create directories on the FTP server. I have tried directory.exists but it doesnt work.Any other way to create directory on the server.Please help me.
0
7223
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
7110
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
7314
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,...
1
7030
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
7482
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
3191
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
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1540
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
411
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...

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.