Guest User

FTP Download

a guest
Jul 7th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.60 KB | None | 0 0
  1. Imports System.IO
  2.  
  3. Public Class Form1
  4.     Private FTPDownloader As New Utilities.FTP.FTPclient
  5.  
  6.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  7.         TextBox2.Text = "Gianfranco"
  8.         TextBox3.Text = ************
  9.         TextBox4.Text = ************
  10.     End Sub
  11.  
  12.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  13.         FTPDownloader.Hostname = TextBox4.Text.Trim
  14.         FTPDownloader.Username = TextBox2.Text
  15.         FTPDownloader.Password = TextBox3.Text
  16.     End Sub
  17.  
  18.     Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  19.         FTPDownloader.CurrentDirectory = "/Concerti"
  20.         RefreshList()
  21.     End Sub
  22.  
  23.     Private Sub RefreshList()
  24.         ListBox1.Items.Clear()
  25.         Try
  26.             For Each file In FTPDownloader.ListDirectoryDetail()
  27.                 ListBox1.Items.Add(file.Filename)
  28.             Next
  29.         Catch ex As Exception
  30.             MessageBox.Show(ex.Message)
  31.         End Try
  32.     End Sub
  33.  
  34.     Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  35.         Try
  36.             If MessageBox.Show("Sei sicuro di voler scaricare il download selezionato? " & ListBox1.SelectedItem, "Conferma", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = DialogResult.OK Then
  37.                 FTPDownloader.Download(ListBox1.SelectedItem, My.Computer.FileSystem.SpecialDirectories.Desktop + "\" + ListBox1.SelectedItem, True)
  38.             End If
  39.         Catch ex As Exception
  40.             MessageBox.Show(ex.Message)
  41.         End Try
  42.     End Sub
  43. End Class
Add Comment
Please, Sign In to add comment