c# – Copy file to a different directory

c# – Copy file to a different directory

string fileToCopy = c:\myFolder\myFile.txt;
string destinationDirectory = c:\myDestinationFolder\;

File.Copy(fileToCopy, destinationDirectory + Path.GetFileName(fileToCopy));
File.Copy(@someDirectorysomeFile.txt, @otherDirectorysomeFile.txt);

works fine.

c# – Copy file to a different directory

MSDN File.Copy

var fileName = sourceFile.txt;
var source = Path.Combine(Environment.CurrentDirectory, fileName);
var destination = Path.Combine(destinationFolder, fileName);

File.Copy(source, destination);

Leave a Reply

Your email address will not be published.