Fix 1 for admin accounts

This commit is contained in:
AsvalGTA 2019-04-18 17:18:21 +02:00
parent de00c36a14
commit 396655f105
2 changed files with 19 additions and 1 deletions

View File

@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8FABCD3A-9D55-4B54-B237-B259D815DEB8}</ProjectGuid>
<OutputType>Exe</OutputType>
<OutputType>WinExe</OutputType>
<RootNamespace>FModel</RootNamespace>
<AssemblyName>FModel</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>

View File

@ -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();