By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,356 Members | 1,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,356 IT Pros & Developers. It's quick & easy.

FTPWebRequest failing - URGENT

P: n/a
I am using .NET 2.0 new classed for FTP download purpose. I have
requirement to connect with 3 different FTP and download all files
list and see if file exist at my end. if not then i need to download.
I am keeping my configuration in XML file so that i can use my same
code and i simply iterate on my configuration data. 1st FTP connect
works fine but 2nd FTP does not connect and return with following
error message. After this failure when my code attemp to for the 3rd
FTP, it works. but it also fail on Download file for 3rd FTP on some
files. I could not find any specific reason for this exception. If i
make my failing FTP as 1st one, so in general my second FTP request in
my loop fails. i tested 3 ftp in internet explorer and they work fine.
but in .NET 2.0 new classes i can see these un knonw behaviours. any
suggestion on improving code or setting some other property which i am
The remote server returned an error: (503) Bad sequence of commands.
I further trace the error line, it is coming on following line,
response = reqFTP.GetResponse()

here is my code below which works well for 1st FTP Request but it
fails on 2nd FTP.
reqFTP = System.Net.FtpWebRequest.Create(New Uri("ftp://"
+ Me.FTP_Address))
reqFTP.KeepAlive = True
reqFTP.UseBinary = True
reqFTP.Credentials = New
System.Net.NetworkCredential(Me.FTP_User, Me.FTP_Password)
reqFTP.Method =
response = reqFTP.GetResponse()
reader = New
System.IO.StreamReader(response.GetResponseStream( ))
line = reader.ReadLine()
While (Not line Is Nothing)
line = reader.ReadLine()
End While
' to remove the trailing ','
result.Remove(result.ToString().LastIndexOf(","), 1)
It is URGENT for me to resolve this issue, otherwise i will have to
switch to a 3rd Party FTP component. I was excited about 2.0 new
classes and i hope this issue will resolve with some one's feedback.

Jun 15 '07 #1
Share this Question
Share on Google+
1 Reply

P: n/a
I figured it out now. 1st of all i was not setting up KeepAlive
property at all. Then i thought i should setup it as TRUE as default
may be FALSE. but it did not work out. Then i setup it to FALSE
explicitly and now every thing is working fine.

Jun 15 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.