frompath:需要拷贝文件的路径
topath:文件被拷贝到哪里的路径
private void streamcopy(string frompath, string topath)
{
FileStream fs1 = new FileStream(frompath, FileMode.Open, FileAccess.Read);
FileStream fs2 = new FileStream(topath, FileMode.Create, FileAccess.Write);
fs1.Seek(0, SeekOrigin.Begin);
fs2.Seek(0, SeekOrigin.Begin);
byte[] by=new byte[1024];
progressBar1.Maximum =(int)fs1.Length;
int total = 0;
int size=0;
while (0!=(size=fs1.Read(by,0,1024)))
{
total = total + size;
progressBar1.Value = total;
fs2.Write(by,0,size);
}
fs1.Flush();
fs2.Flush();
fs1.Dispose();
fs2.Dispose();
fs1.Close();
fs2.Close();
}