myApp.exe
C:\Program Files (x86)\appDir
myApp
File.WriteAllLines( Application.StartupPath + "myFile.txt", new string[]{"test1", "test2", "test3"});
System.UnauthorizedAccessException
"Attempt to perform an unauthorized operation"
appDir
DirectoryInfo dInfo = new DirectoryInfo(Application.StartupPath);DirectorySecurity dSecurity = dInfo.GetAccessControl();FileSystemAccessRule fsar = new FileSystemAccessRule( WindowsIdentity.GetCurrent().Name, FileSystemRights.WriteData, AccessControlType.Allow);dSecurity.AddAccessRule(fsar);dInfo.SetAccessControl(dSecurity);