Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Public Class Form1
- Private FTPDownloader As New Utilities.FTP.FTPclient
- 'Avvio il programma e setto i campi "Username", "Password", "IP Server"
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- TextBox2.Text = "Gianfranco"
- TextBox3.Text = "**************"
- TextBox4.Text = "**************"
- End Sub
- ' Premendo il tasto "Connetti" o Button1, avvio la connessione FTP in attesa venga accettata dal server
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Try
- FTPDownloader.Hostname = TextBox4.Text.Trim
- FTPDownloader.Username = TextBox2.Text
- FTPDownloader.Password = TextBox3.Text
- Catch ex As Exception
- MessageBox.Show(ex.Message)
- End Try
- End Sub
- 'Mostro a schermo i file contenuti all'interno della directory indicata
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- FTPDownloader.CurrentDirectory = "/Concerti"
- RefreshList()
- End Sub
- Private Sub RefreshList()
- ListBox1.Items.Clear()
- Try
- For Each file In FTPDownloader.ListDirectoryDetail()
- ListBox1.Items.Add(file.Filename)
- Next
- Catch ex As Exception
- MessageBox.Show(ex.Message)
- End Try
- End Sub
- 'Avvio il download del file interessato...qui avviene l'errore misterioso
- Private Sub ListBox1_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles ListBox1.MouseDoubleClick
- Try
- If MessageBox.Show("Sei sicuro di voler scaricare il download selezionato? " & ListBox1.SelectedItem, "Conferma", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = DialogResult.OK Then
- FTPDownloader.Download(ListBox1.SelectedItem, My.Computer.FileSystem.SpecialDirectories.Desktop + "\" + ListBox1.SelectedItem)
- End If
- Catch ex As Exception
- MessageBox.Show(ex.Message)
- End Try
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement