27- FTP Application

0
396

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.
    01_helloworld
  • The New Project dialog will appear.
    create2s
    Select “windows” in the project types, hit the “windows form application” in the templates and hit “ok“.
  • Design the form just like this.
    ftpf1app1
  • Double click the button to fire the event handler of it and do this following code.
    [vb] 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)
    req.Method = System.Net.WebRequestMethods.Ftp.UploadFile
    Dim file() As Byte = System.IO.File.ReadAllBytes(txtfileUpload.Text)
    Dim str As System.IO.Stream = req.GetRequestStream()
    str.Write(file, 0, file.Length)
    str.Close()
    str.Dispose()
    End SubEnd Class
    [/vb]

 

Readers might read also:

 

Facebook Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.