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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Connelly
    New Member
    • Jan 2011
    • 103

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

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

    Code:
    DirectorySecurity access = Directory.GetAccessControl(System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
                    access.AddAccessRule(new FileSystemAccessRule(WindowsIdentity.GetCurrent().User, FileSystemRights.CreateDirectories, AccessControlType.Allow));
                    string StudentTracker = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles, Environment.SpecialFolderOption.Create), "StudentTracker");
                    Directory.CreateDirectory(StudentTracker, access);
Working...