FtpWebRequest异步上传 [英] FtpWebRequest asynchronous Upload

查看:59
本文介绍了FtpWebRequest异步上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MSDN中列出的代码将文件上传到FTP服务器
http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest .aspx

我提供服务器凭据,设置模式和超时。并且在回调(EndGetStreamCallback)中,它崩溃在
requestStream = state.Request.EndGetRequestStream(ar);

与以下异常
WebException:远程服务器返回错误:( 550)文件不可用(例如,找不到文件,没有访问权限)。

我查看了我的应用程序和站点的FTP流量,并观察到连接成功但是<它有请求:OPT utf8 on响应:550权限被拒绝。
和PWD(打印工作
目录)是"/ download /"我的路径是"ftp://
ftp.xxx.com/upload/filename.txt"然后尝试用命令"CWD / download / upload /"更改目录
,因为没有这样的目录
存在远程服务器重新上传上面提到的错误
例外。

请告知。

谢谢你的SM

I am uploading file to FTP server asynchronously using the code listed in MSDN.
http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx

I give the server credentials, set  the mode and timeout. And in the callback (EndGetStreamCallback) it crashes at
requestStream = state.Request.EndGetRequestStream(ar);

with following exception
WebException: The remote server returned an error: (550) File unavailable (e.g., file not found, no access).

I looked at the FTP traffic b/w my application and site and observed
that the connection was a success but
it had Request: OPT utf8 on
Response: 550 Permission denied.
and the PWD (Print Working
Directory) was "/download/" and my since i gave a path "ftp://
ftp.xxx.com/upload/filename.txt" it then tries to change the
directory
with the command "CWD /download/upload/", since no such directory
exists remote sever reutrned the error mentioned in the above
exeption.

Please advise.

Thanks
SM

推荐答案

你不能确定在尝试将文件上传到该目录之前,目标目录是否存在?
Shouldnt you make sure that the destination directory exists first, before trying to upload a file into that directory?


这篇关于FtpWebRequest异步上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆