How to send files from one computer to another computer?

pranava

Member
Joined
Apr 2, 2009
Messages
6
Programming Experience
Beginner
Hi

I want to send files from a system to another system(specifically a server) using FTP. Can I do this with VB.NET? If yes, please suggest me the best procedure to do it.
Actually I need to transfer the mail items from outlook to a remote system(server) which is connected to internet. I have extracted the mail body and attachments. I implemented code to send files to a computer in the same network. Its working fine, but not knowing how to send it to another computer using FTP.

Please suggest me a solution for this!

Thanks in advance!
 
Thanks for the reply.

Actually, I want to upload file to a folder which is under apache in a linux server.
Is there any way that I can upload the files by specifying the file name like "http://www.xyz.com/abc/message.txt"?
 
You should use Ftp to upload. The Http server can serve the file from same folder.
 
Ya... but i at first, i tried to do it with http. but in vain. Finally got the solution.
Here is the code...


VB.NET:
Dim ftpRequest As FtpWebRequest
Dim ftpResponse As FtpWebResponse
Try 
    'Settings required to establish a connection with the server
    Me.ftpRequest = CType(FtpWebRequest.Create(New Uri("ftp://ServerIP/FileName")),FtpWebRequest)
    Me.ftpRequest.Method = WebRequestMethods.Ftp.UploadFile
    Me.ftpRequest.Proxy = Nothing
    Me.ftpRequest.UseBinary = true
    Me.ftpRequest.Credentials = New NetworkCredential("UserName", "Password")
    'Selection of file to be uploaded
    Dim ff As FileInfo = New FileInfo("File Local Path With File Name")
    'e.g.: c:\\Test.txt
    Dim fileContents() As Byte = New Byte((ff.Length) - 1) {}
    Dim fr As FileStream = ff.OpenRead
    fr.Read(fileContents, 0, Convert.ToInt32(ff.Length))
    Dim writer As Stream = ftpRequest.GetRequestStream
    writer.Write(fileContents, 0, fileContents.Length)
    Me.ftpResponse = CType(Me.ftpRequest.GetResponse,FtpWebResponse)
    'Gets the FtpWebResponse of the uploading operation
    Response.Write(Me.ftpResponse.StatusDescription)
    'Display response
Catch webex As WebException
    Me.Message = webex.ToString
End Try
 
Last edited by a moderator:
If you had bothered clicking the link in first reply you would have done this with a single line of code 4 days ago.

Also take notice this is a VB.Net forum, I fixed the code dump of your previous post, for future use VB.Net language when posting at these forums.
 
Back
Top