public static void DeleteTestFileFromDirectory(ILogger logger, DirectoryPath directoryPath)
 {
     File.Delete(directoryPath.PathString + DIRECTORYTESTFILE);
     logger.LogDebug(string.Format("Test file {0} deleted.", directoryPath.PathString + DIRECTORYTESTFILE));
 }
 public static void WriteTestFileToDirectory(ILogger logger, DirectoryPath directoryPath)
 {
     File.WriteAllLines(directoryPath.PathString + DIRECTORYTESTFILE, lines);
     logger.LogDebug(string.Format("Test file written {0}.", directoryPath.PathString + DIRECTORYTESTFILE));
 }
Exemplo n.º 3
0
 public static void CreateLocalDirectoryIfNotExistingAndGiveFullControlToAuthenticatedUsers(ILogger logger, DirectoryPath directoryPath)
 {
     CreateLocalDirectoryIfNotExistingAndGiveFullControlToUser(logger, directoryPath, "NT Authority", "Authenticated Users");
 }
Exemplo n.º 4
0
 public static void CreateLocalDirectoryIfNotExistingAndGiveFullControlToUser(ILogger logger, DirectoryPath directoryPath, string domain, string user)
 {
     try
     {
         string account = BuildAccount(logger, domain, user);
         if (!directoryPath.Exists)
         {
             logger.LogDebug(string.Format("Creating directory {0}.", directoryPath));
             directoryPath.CreateDirectory();
         }
         DirectoryInfo     directoryInfo = new DirectoryInfo(directoryPath.PathString);
         DirectorySecurity dSecurity     = directoryInfo.GetAccessControl();
         dSecurity.AddAccessRule(new FileSystemAccessRule(account, FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.NoPropagateInherit, AccessControlType.Allow));
         logger.LogDebug(string.Format("Setting Full control for folder to {0}", account));
         directoryInfo.SetAccessControl(dSecurity);
         if (directoryInfo == null)
         {
             throw new DirectoryException(string.Format("Could not set directory access control for {0} to {1}", directoryPath, account));
         }
     }
     catch (DirectoryException)
     {
         throw;
     }
     catch (Exception ex)
     {
         string error = string.Format("Unknown error sharing folders.", ex.GetType().ToString());
         throw new DirectoryException(error, ex);
     }
 }
Exemplo n.º 5
0
 public static void CreateLocalDirectoryIfNotExistingAndGiveFullControlToEveryone(ILogger logger, DirectoryPath directoryPath)
 {
     CreateLocalDirectoryIfNotExistingAndGiveFullControlToUser(logger, directoryPath, "NT Authority", "Everyone");
 }