Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

FTPWebRequest failing - URGENT

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BizWorld - 15 Jun 2007 20:00 GMT
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
missing?????????????

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 =
System.Net.WebRequestMethods.Ftp.ListDirectory
           response = reqFTP.GetResponse()
           reader = New
System.IO.StreamReader(response.GetResponseStream())
            line = reader.ReadLine()
            While (Not line Is Nothing)
               result.Append(line)
               result.Append(",")
               line = reader.ReadLine()
           End While
            ' to remove the trailing ','
           result.Remove(result.ToString().LastIndexOf(","), 1)
           reader.Close()

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.
BizWorld - 15 Jun 2007 20:34 GMT
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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.