C# 程式製作現有檔案的副本
使用 File.Copy 方法制作現有檔案的副本。
新增要複製的檔案的路徑。
String myPath = @"D:\one.txt";
現在將上述檔案複製到以下檔案 −
String myPath = @"D:\one.txt";
對原始檔和目標檔案使用 File.Copy 方法。
File.Copy(myPath,newpath);
示例
using System; using System.IO; public class Program { public static void Main() { String myPath = @"D:\one.txt"; // the file will get copied here String newpath = @"D:\two.txt"; // copying file File.Copy(myPath,newpath); } }
廣告