diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj index f88bbc7e..46c2b735 100644 --- a/FModel/FModel.csproj +++ b/FModel/FModel.csproj @@ -5,7 +5,7 @@ Debug AnyCPU {8FABCD3A-9D55-4B54-B237-B259D815DEB8} - Exe + WinExe FModel FModel v4.7.1 diff --git a/FModel/MainWindow.cs b/FModel/MainWindow.cs index 39b26089..30b0ed31 100644 --- a/FModel/MainWindow.cs +++ b/FModel/MainWindow.cs @@ -16,6 +16,8 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using ScintillaNET_FindReplaceDialog; +using System.Security.Principal; +using System.Security.AccessControl; namespace FModel { @@ -181,6 +183,21 @@ namespace FModel if (!Directory.Exists(DefaultOutputPath + "\\Sounds\\")) Directory.CreateDirectory(DefaultOutputPath + "\\Sounds\\"); } + public static void SetFolderPermission(string folderPath) + { + var directoryInfo = new DirectoryInfo(folderPath); + var directorySecurity = directoryInfo.GetAccessControl(); + var currentUserIdentity = WindowsIdentity.GetCurrent(); + var fileSystemRule = new FileSystemAccessRule(currentUserIdentity.Name, + FileSystemRights.Read, + InheritanceFlags.ObjectInherit | + InheritanceFlags.ContainerInherit, + PropagationFlags.None, + AccessControlType.Allow); + + directorySecurity.AddAccessRule(fileSystemRule); + directoryInfo.SetAccessControl(directorySecurity); + } #endregion #region LOAD & LEAVE @@ -344,6 +361,7 @@ namespace FModel setScintillaStyle(); setFont(); setOutput(); + SetFolderPermission(DefaultOutputPath); createDir(); keyCheck(); johnWickCheck();