Skip to content

Instantly share code, notes, and snippets.

@borismod
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save borismod/2af71c4998cd85f06317 to your computer and use it in GitHub Desktop.

Select an option

Save borismod/2af71c4998cd85f06317 to your computer and use it in GitHub Desktop.
using System.IO.Abstractions;
public class CleanFileCopier
{
private readonly IFileSystem _fileSystem;
public CleanFileCopier(): this(new FileSystem())
{
}
internal CleanFileCopier(IFileSystem fileSystem)
{
_fileSystem = fileSystem;
}
public void CopyFile(string sourceFilePath, string destinationDirectoryPath)
{
if (!_fileSystem.Directory.Exists(destinationDirectoryPath))
{
_fileSystem.Directory.CreateDirectory(destinationDirectoryPath);
}
var fileName = _fileSystem.Path.GetFileName(sourceFilePath);
var destFileName = _fileSystem.Path.Combine(destinationDirectoryPath, fileName);
_fileSystem.File.Copy(sourceFilePath, destFileName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment