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. Getting Error while Copying File From Local Network [Solved]

Getting Error while Copying File From Local Network [Solved]

Scheduled Pinned Locked Moved Visual Basic
csharpsysadminhelpquestion
5 Posts 3 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.
  • I Offline
    I Offline
    i i i
    wrote on last edited by
    #1

    Thanks in advance, I am getting this error at Ftpwebresponse The underlying connection was closed: An unexpected error occurred on a receive. Const localFile As String = "C:\" Const remoteFile As String = "/Filder/File.ext" Const host As String = "ftp://000.000.0.000" Const username As String = "UserName" Const password As String = "Pwd" Dim URI As String = host & remoteFile Dim ftp As System.Net.FtpWebRequest = CType(System.Net.FtpWebRequest.Create(URI), System.Net.FtpWebRequest) ftp.Credentials = New System.Net.NetworkCredential(username, password) ftp.KeepAlive = False ftp.UseBinary = True ftp.Method = System.Net.WebRequestMethods.Ftp.DownloadFile **Using response As System.Net.FtpWebResponse = CType(ftp.GetResponse, System.Net.FtpWebResponse)** Using responseStream As IO.Stream = response.GetResponseStream Using fs As New IO.FileStream(localFile, IO.FileMode.Create) Dim buffer(2047) As Byte Dim read As Integer = 0 Do read = responseStream.Read(buffer, 0, buffer.Length) fs.Write(buffer, 0, read) Loop Until read = 0 'see Note(1) responseStream.Close() fs.Flush() fs.Close() End Using responseStream.Close() End Using response.Close() End Using Any Suggestions ??

    SOFTDEV Luck in life always exists in the form of an abstract class that cannot be instantiated directly and needs to be inherited by hard work and dedication.

    modified on Monday, March 28, 2011 4:26 AM

    L 1 Reply Last reply
    0
    • I i i i

      Thanks in advance, I am getting this error at Ftpwebresponse The underlying connection was closed: An unexpected error occurred on a receive. Const localFile As String = "C:\" Const remoteFile As String = "/Filder/File.ext" Const host As String = "ftp://000.000.0.000" Const username As String = "UserName" Const password As String = "Pwd" Dim URI As String = host & remoteFile Dim ftp As System.Net.FtpWebRequest = CType(System.Net.FtpWebRequest.Create(URI), System.Net.FtpWebRequest) ftp.Credentials = New System.Net.NetworkCredential(username, password) ftp.KeepAlive = False ftp.UseBinary = True ftp.Method = System.Net.WebRequestMethods.Ftp.DownloadFile **Using response As System.Net.FtpWebResponse = CType(ftp.GetResponse, System.Net.FtpWebResponse)** Using responseStream As IO.Stream = response.GetResponseStream Using fs As New IO.FileStream(localFile, IO.FileMode.Create) Dim buffer(2047) As Byte Dim read As Integer = 0 Do read = responseStream.Read(buffer, 0, buffer.Length) fs.Write(buffer, 0, read) Loop Until read = 0 'see Note(1) responseStream.Close() fs.Flush() fs.Close() End Using responseStream.Close() End Using response.Close() End Using Any Suggestions ??

      SOFTDEV Luck in life always exists in the form of an abstract class that cannot be instantiated directly and needs to be inherited by hard work and dedication.

      modified on Monday, March 28, 2011 4:26 AM

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Do you want to download a file from a FTP-server, or copy a file in your LAN using the filesystem? In the first case; Is the remote PC an FTP server? Can you reach it with a tool like CuteFTP? In the second case; You'll need code to recursively copy folders and files.

      I are Troll :suss:

      I 1 Reply Last reply
      0
      • L Lost User

        Do you want to download a file from a FTP-server, or copy a file in your LAN using the filesystem? In the first case; Is the remote PC an FTP server? Can you reach it with a tool like CuteFTP? In the second case; You'll need code to recursively copy folders and files.

        I are Troll :suss:

        I Offline
        I Offline
        i i i
        wrote on last edited by
        #3

        Thanks for the reply , well i was trying to download file :cool: from a machine on the local network, Cute FTP even cannot access it. thanks i think so i got the answer , but anyhow is it possible that we user FTP on a network, what is proffered to copy files on a network , i used File Copy API at last.

        SOFTDEV Luck in life always exists in the form of an abstract class that cannot be instantiated directly and needs to be inherited by hard work and dedication.

        D 1 Reply Last reply
        0
        • I i i i

          Thanks for the reply , well i was trying to download file :cool: from a machine on the local network, Cute FTP even cannot access it. thanks i think so i got the answer , but anyhow is it possible that we user FTP on a network, what is proffered to copy files on a network , i used File Copy API at last.

          SOFTDEV Luck in life always exists in the form of an abstract class that cannot be instantiated directly and needs to be inherited by hard work and dedication.

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

          FTP won't work unless the server you're copying from is running an FTP server. If this is a local network, I doubt it's runnig FTP. You're more likely copying files from a shared folder on the server. To get at those, you simply have to supply the normal File copy method and supply either a mapped drive letter path to the source, or a UNC path.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak

          I 1 Reply Last reply
          0
          • D Dave Kreskowiak

            FTP won't work unless the server you're copying from is running an FTP server. If this is a local network, I doubt it's runnig FTP. You're more likely copying files from a shared folder on the server. To get at those, you simply have to supply the normal File copy method and supply either a mapped drive letter path to the source, or a UNC path.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak

            I Offline
            I Offline
            i i i
            wrote on last edited by
            #5

            Thanks, Solved

            SOFTDEV Luck in life always exists in the form of an abstract class that cannot be instantiated directly and needs to be inherited by hard work and dedication.

            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