예제 #1
0
        private void ManipulateFile(Action<MyFileInfo, string> fileAction, MyFileInfo file, string destinationPath, bool force = false)
        {
            var destination = _fileSystem.DirectoryInfo.FromDirectoryName(destinationPath);

            if (!destination.Exists && !force)
                throw new IOException(string.Format("The system cannot find the path specified. {0}", destinationPath));

            var destinationFullName = _fileSystem.Path.Combine(destinationPath, file.RelativePath);
            var destinationFile = _fileSystem.FileInfo.FromFileName(destinationFullName);

            if (!destinationFile.Directory.Exists)
            {
                CreateDirectory(destinationFile.Directory.FullName);
            }

            fileAction(file, destinationFullName);
        }
예제 #2
0
        public void CopyFile(MyFileInfo file, string destinationPath, bool overwrite = false, bool force = false)
        {
            var copyFile = new Action<MyFileInfo, string>((f, destinationFullPath) => f.File.CopyTo(destinationFullPath, overwrite));

            ManipulateFile(copyFile, file, destinationPath, force);
        }
예제 #3
0
        public void MoveFile(MyFileInfo file, string destinationPath, bool force = false)
        {
            var moveFile = new Action<MyFileInfo, string>((f, destinationFullPath) => f.File.MoveTo(destinationFullPath));

            ManipulateFile(moveFile, file, destinationPath, force);
        }