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