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);
        }
Esempio n. 2
0
        ///<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);
        }