使用webClinet claass下载时处理异常 [英] Handle exception when downloading with webClinet claass
本文介绍了使用webClinet claass下载时处理异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我想通过.net框架中的WebClinet类从Internet下载文件
当我的实例正在下载(如果我断开与互联网的连接)时,它将在program.cs类中引发异常.
与Internet断开连接时如何处理此异常.
玩得开心.
Hi everybody
I want download file from internet by WebClinet class in .net framework
When my instance is downloading if i disconnect from internet it throw exception in program.cs class.
how can i handle this exception when disconnect from internet .
have a good time.
推荐答案
使用WebException
.
请查看以下链接以获取更多信息.
http://stackoverflow.com/questions/5999215/exception-handling-网络客户端下载字符串的正确方法
http://www.albahari.com/nutshell/ch14.aspx
WebException类
UseWebException
.
Have a look at below links for more information.
http://stackoverflow.com/questions/5999215/exception-handling-the-right-way-for-webclient-downloadstring
http://www.albahari.com/nutshell/ch14.aspx
WebException Class
您可以使用WebException
-这将为您处理大多数错误.
请参见此处 [
You can useWebException
- this will handle most errors for you.
See here[^] for more information on different types of exceptions that could be used withWebClient
.
这篇关于使用webClinet claass下载时处理异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文