首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VB 2013 DownloadFile错误/异常

VB 2013 DownloadFile错误/异常
EN

Stack Overflow用户
提问于 2014-07-17 17:07:41
回答 1查看 1.6K关注 0票数 1

尝试使用My.Computer.Network.DownloadFile从VB 2013 Express中的FTP服务器获取文件。当文件在那里的时候,一切都很好。但是,当找不到文件时,我无法捕获结果。使用尝试-捕捉,但它从来没有击中捕获。它会引发一个“应用程序中发生了未处理的异常.”错误。

任何帮助都将不胜感激!

代码语言:javascript
复制
Try
   My.Computer.Network.DownloadFile(server_name, file_name, user_name, password, False, 500, True)
Catch ex As ArgumentException
   MsgBox(ex.GetType().ToString())
Catch ex As TimeoutException
   MsgBox(ex.GetType().ToString()) 'Label1.Text = ex
End Try
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-17 17:21:25

看看文献资料 --您没有捕获几乎所有DownloadFile可能抛出的异常类型。

代码语言:javascript
复制
The following conditions may cause an exception to be thrown:
  The drive name is not valid (ArgumentException).
  destinationFileName ends with a trailing slash (ArgumentException).
  overwrite is set to False and the destination file already exists (IOException).
  The server does not respond within the specified connectionTimeout (TimeoutException).
  The authentication fails (SecurityException).
  User lacks necessary permissions (SecurityException).
  The request is denied by the website (WebException).

试着

代码语言:javascript
复制
Try
   My.Computer.Network.DownloadFile(server_name, file_name, user_name, password, False, 500, True)
Catch ex As Exception
   MsgBox(ex.GetType().ToString())

看看是怎么回事。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24809578

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档