System.Net.WebClient webClient=new System.Net.WebClient();
Stream stream = webClient.OpenRead(SourceURL);
byte[] arrByte = new byte[1024];
long completedByteCount = 0;
if (File.Exists(DestPath))
{
File.Delete(DestPath);
}
FileStream fStream = new FileStream(DestPath,FileMode.CreateNew,FileAccess.Write);
while(true)
{
int readCnt = stream.Read(arrByte,0,1024);
if(readCnt==0) break;     
fStream.Write(arrByte,0,readCnt);
completedByteCount += readCnt;
double percent=(int)((float)completedByteCount / FileLength*100) ;
CompletedProseccEventArgs e=new CompletedProseccEventArgs(percent,completedByteCount);
OnCompletedProsecc(e);
}             
stream.Close();
fStream.Close();

里面有些代码是为了控件进度条

相关文章:

  • 2022-12-23
  • 2021-07-08
  • 2021-12-01
  • 2022-12-23
  • 2021-08-24
  • 2021-06-28
  • 2021-12-29
  • 2022-12-23
猜你喜欢
  • 2021-12-15
  • 2022-02-11
  • 2022-12-23
  • 2021-09-09
  • 2021-06-30
  • 2022-12-23
  • 2021-07-27
相关资源
相似解决方案