protected virtual void CreateNonExistingFile(string path)
        {
            // copy from default location
            File.Copy(Path.Combine(Installation.Properties.DefaultConfigurationDirectory, Filename), path);

            // allow everyone to write to the config
            FilePermissions.SetAclForUserOnFile(path, FilePermissions.EveryoneIdentity, FileSystemRights.FullControl, AccessControlType.Allow);
        }
Пример #2
0
        private static void EnsurePermissionSettings()
        {
            var rights   = FileSystemRights.CreateDirectories | FileSystemRights.CreateFiles | FileSystemRights.ListDirectory | FileSystemRights.Modify | FileSystemRights.DeleteSubdirectoriesAndFiles;
            var everyone = FilePermissions.EveryoneIdentity;

            if (Installation.GetFileLayoutType() == FileLayoutType.Installed)
            {
                FilePermissions.SetAclForUserOnDirectory(Installation.GetConfigurationDirectory(), everyone, rights, AccessControlType.Allow);
                foreach (var file in Directory.GetFiles(Installation.GetConfigurationDirectory(), "*.xml"))
                {
                    FilePermissions.SetAclForUserOnFile(file, everyone, rights, AccessControlType.Allow);
                }
            }

            FilePermissions.SetAclForUserOnDirectory(Installation.GetCacheDirectory(), everyone, rights, AccessControlType.Allow);
            FilePermissions.SetAclForUserOnDirectory(Installation.GetLogDirectory(), everyone, rights, AccessControlType.Allow);
        }