.NET Framework Developer Center >
.NET Development Forums
>
Network Class Library (System.Net)
>
FtpWebRequest asynchronous Upload
FtpWebRequest asynchronous Upload
- 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
All Replies
- Shouldnt you make sure that the destination directory exists first, before trying to upload a file into that directory?
feroze
--
My blog
Instruction on how to create a tracelog with your System.Net application
- Directory is in place. Everything looks good.
If i login through a FTP Client (CoreFTP), it uploads smoothly. But there seems to be some issue with asynchronous upload through code.
Thanks - Run a Wireshark trace of the working FTP scenario and save it. Then run the same trace (exact commands from working scenario) and compare the two traces. You will see a differnce that will help you zero in on where things are going wrong.
Javaman - FtpWebRequest assumes that the path in the URL is relative to the home directory on the FTP server. To have it do a absolute CD "/foobar", then the path needs to have an extra slash at the front. So you need to use e.g. ftp://ftp.xxx.com/%2Fupload/filename.txt Note the "%2F" See http://blogs.msdn.com/mariya/archive/2006/03/06/544523.aspx for the details!
http://www.alanjmcf.me.uk/ Please follow-up in the newsgroup. If I help, mark the question answered- Proposed As Answer byFeroze Daud Sunday, November 01, 2009 1:21 AM


