How to copy or move a file from one location to another location in csharpIntroduction
In this code snippet I will show you how you can copy or move a file from one location to another location in charp.
To copy a file from one location to another location
File.Copy( "c:\\myFolder\\myFile.txt", "c:\\NewFolder\\myFile.txt");
If you want to change the name of the file while copying the file, use the code below.
File.Copy( "c:\\myFolder\\oldfile.txt", "c:\\NewFolder\\newfile.txt");
To move a file from one location to another location
File.Move( "c:\\myFolder\\myFile.txt", "c:\\NewFolder\\myFile.txt");
Same way as in the case of copy if you want to change the name of the file while copying the file, use the code below.
File.Move( "c:\\myFolder\\oldfile.txt", "c:\\NewFolder\\newfile.txt");
Enjoy Coding........