1 class Program 2 { 3 static void Main(string[] args) 4 { 5 string source = @"F:\361\android studio\4.0\亲情奉献-全套精品.Net基础班视频教程-video\亲情奉献全套精品.Net基础视频教程之10-面向对象多态\(第十二天)\video/13、模拟移动硬盘、U盘、MP3.avi"; 6 string target = @"C:\Users\dell-\Desktop/new.avi"; 7 copy(source, target); 8 Console.WriteLine("ok"); 9 10 } 11 public static void copy(string source, string target) 12 { 13 using (FileStream fsread = new FileStream(source, FileMode.Open, FileAccess.Read)) 14 { 15 using (FileStream fswrite = new FileStream(target, FileMode.OpenOrCreate, FileAccess.Write)) 16 { 17 byte[] b = new byte[1024 * 1024 * 5]; 18 while (true) 19 { 20 int a = fsread.Read(b, 0, b.Length); 21 if(a==0) 22 { 23 break; 24 } 25 fswrite.Write(b, 0, a); 26 } 27 28 } 29 } 30 } 31 }
原文:http://www.cnblogs.com/chang-hao/p/5413700.html