using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dome
{
class Program
{
static void Main(string[] args)
{
//大文件拷贝实例
string source = @"E:\Develop Tools\VS2010.iso";
string target = @"D:\VS2010.iso";
CopyFile(source,target);
Console.ReadKey();
}
private static void CopyFile(string source, string target)
{
//1,创建一个读取文件流
using (FileStream fs = new FileStream(source,FileMode.Open))
{
//2,创建一个写入文件流
using (FileStream fsWrite = new FileStream(target,FileMode.Create))
{
//3,创建一个读取文件,写入文件的缓冲区
byte[] buffer = new byte[1024 * 1024 * 10];
//4,开始读写文件
while (true)
{
int r = fs.Read(buffer, 0, buffer.Length);
//文件读取完毕
if (r<=0)
{
break;
}
else
{
fsWrite.Write(buffer, 0, r);
}
}
}
}
}
}
}
阅读(1383) | 评论(0) | 转发(0) |