public DirectoryTruncator(string targetDirectory, IFileSystemWrapper fileSystemWrapper) { if (string.IsNullOrWhiteSpace(targetDirectory)) throw new ArgumentException(); _targetDirectory = targetDirectory; _fileSystemWrapper = fileSystemWrapper ?? new FileSystemWrapper(); if (!_fileSystemWrapper.DirectoryExists(targetDirectory)) throw new ArgumentException("The target directory {0} does not exist", targetDirectory); }
///<summary> /// Moves a file to a destination ///</summary> ///<param name="destination">the new location of the file</param> public File To(string destination) { if (_fileSystemWrapper.DirectoryExists(destination)) { destination = Path.Combine(destination, _file.FileName()); } FailableActionExecutor.DoAction(OnError, _fileSystemWrapper.MoveFile, _file.ToString(), destination); _file.Path = destination; return(_file); }