Network.Downloadfile 总是返回“没有这样的文件或目录”
我正在尝试使用 My.Computer.Network.DownloadFile 从 ftp 服务器下载文件。每次我尝试使用以下命令下载文件:
My.Computer.Network.DownloadFile("ftp://xxx.xx.xxx.40/datafiles/sm/viewcontrol.ip","c:\rdp\viewcontrol.ip", "username","password",false,10000,true)
我在要下载的文件中收到以下错误:
服务器错误消息
ISA 服务器:扩展错误消息:
200 类型设置为 I。200
PORT 命令成功。
550 /datafiles/sm/viewcontrol.ip:没有这样的文件或目录。
我也尝试过 WebClient 并得到完全相同的错误。我只在代码中遇到这个问题。文件夹和文件名正确,用户可以使用 DOS FTP 和 Internet Explorer 手动下载文件。
I am attempting to use My.Computer.Network.DownloadFile to download a file from an ftp server. Everytime I attempt to download the file using:
My.Computer.Network.DownloadFile("ftp://xxx.xx.xxx.40/datafiles/sm/viewcontrol.ip","c:\rdp\viewcontrol.ip","username","password",false,10000,true)
I receive the following error within the file that is to be downloaded:
Server error message
ISA Server: extended error message :
200 Type set to I.
200 PORT command successful.
550 /datafiles/sm/viewcontrol.ip: No such file or directory.
I have tried WebClient as well and get the exact same error. I only have this problem in code. The folder and the file name are correct and the user is able to download the file manually using DOS FTP and Internet explorer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
回答 1
回答 2
指定的
Username
和Password
参数可以仅用于HTTP。尝试在 URL 中指定用户名和密码,例如Anwser 3
使用 绝对路径,尝试更改代码以包含
%2f
,如下所示:Answer 1
Answer 2
The specified
Username
andPassword
parameters could be just for HTTP. Try specifying both the username and password in the URL e.g.Anwser 3
Something strange about the use of absolute paths, try changing your code to include
%2f
like this:为了让它工作,我转而使用 FTPWebRequest。最初,我遇到了同样的错误。但是,由于正在下载的文件是文本文件,因此我将 UseBinary 属性更改为 False 并且它有效。
In order to get this to work I switched to using FTPWebRequest. Initially, I was getting the same error. However, since the file being downloaded is a text file, I changed the UseBinary property to False and it worked.