private static void BigFileCopy(string source, string target)
{
using (FileStream fsRead = File.OpenRead(source))
{
using (FileStream fsWrite = File.OpenWrite(target))
{
byte[] bytes = new byte[5 * 1024 * 1024];//定义5M空间
int count = 0;
while ((count = fsRead.Read(bytes, 0, bytes.Length)) > 0)
{
fsWrite.Write(bytes, 0, count);
//fsRead.Position 表示已经读取的字节个数
double per = (fsRead.Position / (double)fsRead.Length) * 100;
Console.WriteLine($"{per:0.00}%");
}
}
}
}
C# FileStream实现大文件拷贝
最新推荐文章于 2024-05-16 19:23:03 发布