public ZlpDirectoryInfo CreateSubdirectory(string name) { var path = ZlpPathHelper.Combine(FullName, name); ZlpIOHelper.CreateDirectory(path); return(new ZlpDirectoryInfo(path)); }
public static void SafeCheckCreateDirectory( string folderPath) { Trace.TraceInformation(@"About to safe check-create folder '{0}'.", folderPath); if (!string.IsNullOrEmpty(folderPath) && !SafeDirectoryExists(folderPath)) { try { ZlpIOHelper.CreateDirectory(folderPath); } catch (UnauthorizedAccessException x) { Trace.TraceWarning( @"Caught UnauthorizedAccessException while safe check-creating folder '{0}'. {1}", folderPath, x.Message); } catch (Win32Exception x) { Trace.TraceWarning(@"Caught IOException while safe check-creating folder '{0}'. {1}", folderPath, x.Message); } } else { Trace.TraceInformation( @"Not safe check-creating folder '{0}', because the folder is null or already exists.", folderPath); } }
public static void SafeCopyFile( string sourcePath, string dstFilePath, bool overwrite = true) { Trace.TraceInformation(@"About to safe-copy file from '{0}' to '{1}' " + @"with overwrite = '{2}'.", sourcePath, dstFilePath, overwrite); if (sourcePath == null || dstFilePath == null) { Trace.TraceInformation( string.Format( @"Source file path or destination file path does not exist. " + @"Not copying." )); } else { if (string.Compare(sourcePath, dstFilePath, StringComparison.OrdinalIgnoreCase) == 0) { Trace.TraceInformation(@"Source path and destination path are the same: " + @"'{0}' is '{1}'. Not copying.", sourcePath, dstFilePath); } else { if (SafeFileExists(sourcePath)) { if (overwrite) { SafeDeleteFile(dstFilePath); } var d = ZlpPathHelper.GetDirectoryPathNameFromFilePath(dstFilePath); if (!ZlpIOHelper.DirectoryExists(d)) { Trace.TraceInformation(@"Creating non-existing folder '{0}'.", d); ZlpIOHelper.CreateDirectory(d); } ZlpIOHelper.CopyFile(sourcePath, dstFilePath, overwrite); } else { Trace.TraceInformation(@"Source file path to copy does not exist: '{0}'.", sourcePath); } } } }
public static void SafeMoveFile( string sourcePath, string dstFilePath) { Trace.TraceInformation(@"About to safe-move file from '{0}' to '{1}'.", sourcePath, dstFilePath); if (sourcePath == null || dstFilePath == null) { Trace.TraceInformation( string.Format( @"Source file path or destination file path does not exist. " + @"Not moving." )); } else { if (SafeFileExists(sourcePath)) { SafeDeleteFile(dstFilePath); var d = ZlpPathHelper.GetDirectoryPathNameFromFilePath(dstFilePath); if (!ZlpIOHelper.DirectoryExists(d)) { Trace.TraceInformation(@"Creating non-existing folder '{0}'.", d); ZlpIOHelper.CreateDirectory(d); } ZlpIOHelper.MoveFile(sourcePath, dstFilePath); } else { Trace.TraceInformation(@"Source file path to move does not exist: '{0}'.", sourcePath); } } }
public void Create() { ZlpIOHelper.CreateDirectory(FullName); }
public void Create() { ZlpIOHelper.CreateDirectory(_path); }