27- FTP Application

0
313

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.
    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 13 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here