27- FTP Application


This Visual Basic Tutorial is all about FTP Application.
In this tutorial, we will learn on how to create FTP Application.


Let’s Begin.

  • Open the Visual Basic, select “File” on the menu, hit new and create a new project.
  • The New Project dialog will appear.
    Select “windows” in the project types, hit the “windows form application” in the templates and hit “ok“.
  • Design the form just like this.
  • Double click the button to fire the event handler of it and do this following code.
    1. Public Class Form1Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickDim req As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create(txtsiteroot.Text), System.Net.FtpWebRequest)req.Credentials = New System.Net.NetworkCredential(txtusername.Text, txtpass.Text)
    2. req.Method = System.Net.WebRequestMethods.Ftp.UploadFile
    3. Dim file() As Byte = System.IO.File.ReadAllBytes(txtfileUpload.Text)
    4. Dim str As System.IO.Stream = req.GetRequestStream()
    5. str.Write(file, 0, file.Length)
    6. str.Close()
    7. str.Dispose()
    8. End SubEnd Class


Readers might read also:


Facebook Comments
(Visited 16 times, 1 visits today)


Please enter your comment!
Please enter your name here