如何在C#中复制文件

我想在C#中将文件从A复制到B. 我怎么做?

File.Copy方法:

MSDN链接

没有任何error handling代码:

File.Copy(path, path2); 

使用FileInfo类。

 FileInfo fi = new FileInfo("a.txt"); fi.CopyTo("b.txt"); 

System.IO.File.Copy

这应该工作!

 using System.IO; ... var path = //your current filePath var outputPath = //the directory where you want your (.txt) file File.Copy(path,outputPath);