标签:
class Program { static void Main(string[] args) { //FileStream 拷贝方法封装 using(Stream fs = new FileStream(@"C:\Users\Administrator\Desktop\C#OOP练习\du.txt",FileMode.Open)) using(Stream fs1 = new FileStream(@"C:\Users\Administrator\Desktop\C#OOP练习\xie.txt",FileMode.Create)) { Copy(fs, fs1, 4); } Console.WriteLine("拷贝完成"); } static void Copy(Stream Du, Stream Xie, int size)//文件读,文件写,读取多少 { byte[] bytes = new byte[size]; int len = 0; while ((len = Du.Read(bytes, 0, bytes.Length)) > 0) { Xie.Write(bytes, 0, len); } } }
标签:
原文地址:http://www.cnblogs.com/phpweige/p/4775412.html