FtpWebRequest
-
Hi, I have a small FTP class, written in VB.NET 2.0, which keeps polling for a particular file at a remote location, at 2 minute intervals, till it successfully downloads the file, and then it stops. So far I had been using wget as an external process, and recently I have switched to using the FtpWebRequest class. Now what i have noticed is that the first attempt always fails, even if the particular file is available on the remote server. The error returned is
System.Net.WebException
. However, in the next run, after 2 minutes, the process succeeds, with exactly the same parameters. The relevant part of the code:Dim myFtpWebRequest As FtpWebRequest
Dim myFtpWebResponse As FtpWebResponse
Dim myStreamWriter As StreamWriter
Dim strURL As String = ""strURL = "ftp://" & strFTPURL & strFTPFolder & strFileName myFtpWebRequest = DirectCast(WebRequest.Create(strURL), FtpWebRequest) myFtpWebRequest.KeepAlive = False myFtpWebRequest.Timeout = 20000 myFtpWebRequest.UsePassive = blnUsePassive myFtpWebRequest.UseBinary = True myFtpWebRequest.Credentials = New NetworkCredential(strFTPUserName, strFTPPassword) myFtpWebRequest.Method = WebRequestMethods.Ftp.DownloadFile myFtpWebResponse = myFtpWebRequest.GetResponse()
Can someone throw some light on this? Regards RB
-
Hi, I have a small FTP class, written in VB.NET 2.0, which keeps polling for a particular file at a remote location, at 2 minute intervals, till it successfully downloads the file, and then it stops. So far I had been using wget as an external process, and recently I have switched to using the FtpWebRequest class. Now what i have noticed is that the first attempt always fails, even if the particular file is available on the remote server. The error returned is
System.Net.WebException
. However, in the next run, after 2 minutes, the process succeeds, with exactly the same parameters. The relevant part of the code:Dim myFtpWebRequest As FtpWebRequest
Dim myFtpWebResponse As FtpWebResponse
Dim myStreamWriter As StreamWriter
Dim strURL As String = ""strURL = "ftp://" & strFTPURL & strFTPFolder & strFileName myFtpWebRequest = DirectCast(WebRequest.Create(strURL), FtpWebRequest) myFtpWebRequest.KeepAlive = False myFtpWebRequest.Timeout = 20000 myFtpWebRequest.UsePassive = blnUsePassive myFtpWebRequest.UseBinary = True myFtpWebRequest.Credentials = New NetworkCredential(strFTPUserName, strFTPPassword) myFtpWebRequest.Method = WebRequestMethods.Ftp.DownloadFile myFtpWebResponse = myFtpWebRequest.GetResponse()
Can someone throw some light on this? Regards RB
What is the error message IN the WebException?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
What is the error message IN the WebException?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...The error thrown is
"The operation has timed out"
Thanks/RB -
The error thrown is
"The operation has timed out"
Thanks/RBFirst, do NOT send emails directly to a person. They will get back to your question when they can, NOT when you damand it. Sending me an a direct email to answer your question is extremely rude.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
First, do NOT send emails directly to a person. They will get back to your question when they can, NOT when you damand it. Sending me an a direct email to answer your question is extremely rude.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...Relax, mate....I don't think there is an need to get hyper about it. You have been most helpful in the past. My thinking is that posts that do not see much activity for more than a couple of days seldom get far, I thought it better to jog you into a response. I am sorry if you take offense at such things. RB