How To Upload File on FTP from vb.net
  • First Enable FTP on Server Machine


    Imports System.IO
    Imports System.Net

    Dim request As FtpWebRequest = WebRequest.Create(txt_ftpurl.Text + "/Attachments/" + onlyFileName)
    request.Credentials = New NetworkCredential(txt_username.Text, txt_password.Text)


    request.Method = WebRequestMethods.Ftp.UploadFile
    Dim ftpstream As Stream = request.GetRequestStream
    Dim fstream As FileStream = File.OpenRead(txt_uploatpath.Text)


    Dim data As Byte() = File.ReadAllBytes(txt_uploatpath.Text)
    Dim bytesread As Integer = 0
    bytesread = fstream.Read(data, 0, data.Length)


    ftpstream.Write(data, 0, bytesread)
    ftpstream.Close()
    fstream.Close()


    lbl_status.Text = "File Sussesfully Upload"
    lbl_status.ForeColor = Color.Green



Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week

    Optimum Creative