标签:
文件传送
1 class Program 2 { 3 4 static void Main(string[] args) 5 { 6 // string source = @"E:\教学视频\net基础全套视频2014班\传智播客.Net学院--特供精品.Net基础全套视频教程2014版\特供精品.Net基础全套视频教程2014版--03c#高级\03--面向对象多态\特供.Net基础全套视频教程2014版(第十二天)\video\4、装向和拆箱.avi"; 7 // string target = @"C:\Users\Administrator\Desktop\target.avi"; 8 //// CopyFile(source, target); 9 // File.Copy(source, target); 10 11 Console.Read(); 12 13 14 15 16 } 17 public static void CopyFile(string source, string target) 18 { 19 using(FileStream fsRead=new FileStream(source,FileMode.OpenOrCreate,FileAccess.Read)) 20 { 21 using(FileStream fsWrite=new FileStream(target,FileMode.OpenOrCreate,FileAccess.Write)) 22 { 23 byte[] buffer = new byte[1024*1024*5]; 24 while (true) 25 { 26 int r = fsRead.Read(buffer, 0, buffer.Length); 27 if (r == 0) 28 { 29 break; 30 } 31 fsWrite.Write(buffer, 0, r); 32 } 33 } 34 } 35 } 36 }
标签:
原文地址:http://www.cnblogs.com/ChineseMoonGod/p/5203918.html