Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. FtpWebRequest

FtpWebRequest

Scheduled Pinned Locked Moved Visual Basic
csharpsysadminhelpquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Archimedes24
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • A Archimedes24

      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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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...

      A 1 Reply Last reply
      0
      • D Dave Kreskowiak

        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...

        A Offline
        A Offline
        Archimedes24
        wrote on last edited by
        #3

        The error thrown is "The operation has timed out" Thanks/RB

        D 1 Reply Last reply
        0
        • A Archimedes24

          The error thrown is "The operation has timed out" Thanks/RB

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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...

          A 1 Reply Last reply
          0
          • D Dave Kreskowiak

            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...

            A Offline
            A Offline
            Archimedes24
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups