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?
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);