编写程序,将文件复制到指定路径,允许改写同名的目标文件。 【解答】 using System; using System.IO; class Test { public static void Main() { string path = @"c:/temp/MyTest.txt"; string path2 = path + "temp"; try { using (FileStream fs = File.Create(path)) { } File.Delete(path2); File.Copy(path, path2); Console.WriteLine("{0}拷贝到:{1}", path, path2); File.Copy(path, path2, true); Console.WriteLine("第二次拷贝成功"); } catch { Console.WriteLine("重复拷贝不允许"); } } }