将文件11.txt读出来,再写入11_副本.txt里面。
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.IO; 6 7 namespace ConsoleApplication1 8 { 9 class Program 10 { 11 static void Main(string[] args) 12 { 13 FileStream aFile = new FileStream(@"C:UsersAdministratorDesktop11.txt",FileMode.OpenOrCreate); 14 StreamReader aa = new StreamReader(aFile); 15 FileStream bFile = new FileStream(@"C:UsersAdministratorDesktop11_副本.txt", FileMode.OpenOrCreate); 16 StreamWriter bb = new StreamWriter(bFile); 17 string res = aa.ReadLine(); 18 19 while (res != null) 20 { 21 bb.WriteLine(res); 22 res = aa.ReadLine(); 23 } 24 aa.Close(); 25 aFile.Close(); 26 bb.Close(); 27 bFile.Close(); 28 29 } 30 31 } 32 }