|
这里是我自己写的下载类中的函数
public void download(string url, string dir,string FileName, Boolean asy=false) {
if (asy == true) {
downWebClient = new WebClient();//创建webclient对象
//保存文件
_savePath = dir + FileName;
Uri uri = new Uri(url);
downWebClient.DownloadFileCompleted += new AsyncCompletedEventHandler(downWebClient_DownloadFileCompleted);
downWebClient.DownloadFileAsync(uri,_savePath);
}
}
void downWebClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
if (e.Cancelled)
{
MessageBox.Show("下载已被取消" + e.Error.ToString());
}
else
{
downWebClient.Dispose();//下载完毕释放资源
StrackListForm sf = new StrackListForm();
sf.DownloadOk(true);
}
}
附上 StrackListForm.cs
/// <summary>
/// 修改下载状态
/// </summary>
/// <param name="status"></param>
public void DownloadOk(Boolean status)
{
_isComplete = status;
}
不知道是哪的问题,文件下载的只有一部分,
|
|