为 webClient.DownloadFile() 设置超时 [英] Set timeout for webClient.DownloadFile()
本文介绍了为 webClient.DownloadFile() 设置超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 webClient.DownloadFile()
下载文件,我可以为此设置超时,以便在无法访问文件时不会花费很长时间吗?>
I'm using webClient.DownloadFile()
to download a file can I set a timeout for this so that it won't take so long if it can't access the file?
推荐答案
尝试 WebClient.DownloadFileAsync()
.您可以使用自己的超时时间通过计时器调用 CancelAsync()
.
Try WebClient.DownloadFileAsync()
. You can call CancelAsync()
by timer with your own timeout.
这篇关于为 webClient.DownloadFile() 设置超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文