如何停止或重置Web客户端下载过程 [英] How do I stop or reset web client downloading process
本文介绍了如何停止或重置Web客户端下载过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何停止Web客户端下载过程并保存它
然后再次重置该过程
我不喜欢我想要返回下载过程开始我要保存它
我尝试过:
How to stop web client downloading process and save it
and after that reset the process again
I don't want return downloading process to start I want to save it
What I have tried:
void start()
{
Uri source = new Uri(comboBox1.Text);
file = source.ToString();
button1.Text = "Stop";
wc.OpenRead(source);
path = comboBox2.Text;
wc.DownloadProgressChanged += (s, z) =>
{
label3.Text = $"Downloaded as MB: {((float)z.BytesReceived / 1048576).ToString("#.#")}";
label4.Text = $"Downloaded {z.ProgressPercentage}%";
progressBar1.Value = z.ProgressPercentage;
timer1.Start();
};
wc.DownloadFileAsync(source, path + Path.GetFileName(source.ToString()));
button3.Visible = true;
}
void stop()
{
wc.CancelAsync();
button1.Text = "Start";
}
推荐答案
下载为MB:{((float)z.BytesReceived / 1048576)。的ToString( ##)};
label4.Text =
"Downloaded as MB: {((float)z.BytesReceived / 1048576).ToString("#.#")}"; label4.Text =
Downloaded {z.ProgressPercentage}%;
progressBar1.Value = z.ProgressPercentage;
timer1.Start();
};
wc.DownloadFileAsync(source,path + Path.GetFileName(source.ToString()));
button3.Visible = true;
}
void stop()
{
wc.CancelAsync();
button1.Text =开始;
}
"Downloaded {z.ProgressPercentage}%"; progressBar1.Value = z.ProgressPercentage; timer1.Start(); }; wc.DownloadFileAsync(source, path + Path.GetFileName(source.ToString())); button3.Visible = true; } void stop() { wc.CancelAsync(); button1.Text = "Start"; }
这篇关于如何停止或重置Web客户端下载过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文