Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Private FTPDownloader As New Utilities.FTP.FTPclient
- Private isFolder As Boolean = False
- Private isUpdating As Boolean = False
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- btnChangeDirectory.Enabled = False
- FTPDownloader.Hostname = TextBox1.Text.Trim
- FTPDownloader.Username = TextBox2.Text
- FTPDownloader.Password = TextBox3.Text
- End Sub
- 'ADD BRUTEFORCER AND PROXY SUPPORT
- Private Sub btnHomeDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHomeDir.Click
- FTPDownloader.CurrentDirectory = "/"
- RefreshList()
- UpdateDirectoryLabel()
- End Sub
- Private Sub RefreshList()
- ListFTPfiles.Items.Clear()
- Try
- For Each File In FTPDownloader.ListDirectoryDetail
- ListFTPfiles.Items.Add(File.Filename)
- Next
- Catch ex As Exception
- MessageBox.Show(ex.Message)
- End Try
- End Sub
- Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownload.Click
- If ListFTPfiles.SelectedIndex <> -1 Then
- If MessageBox.Show("Would you like to download" & ListFTPfiles.SelectedItem, "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
- FTPDownloader.Download(ListFTPfiles.SelectedItem, My.Computer.FileSystem.SpecialDirectories.MyDocuments + "\" + ListFTPfiles.SelectedItem, True)
- MessageBox.Show("The file has been downloaded to My Documents", "Download Finished!", MessageBoxButtons.OK, MessageBoxIcon.Information)
- Else
- MessageBox.Show("Download aborted", "Download Aborted", MessageBoxButtons.OK, MessageBoxIcon.Information)
- End If
- Else
- MessageBox.Show("Please select a file!", "Select a file.", MessageBoxButtons.OK, MessageBoxIcon.Information)
- End If
- End Sub
- Private Sub btnChangeDirectory_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChangeDirectory.Click
- FTPDownloader.CurrentDirectory += ListFTPfiles.SelectedItem + "/"
- RefreshList()
- UpdateDirectoryLabel()
- End Sub
- Private Sub UpdateDirectoryLabel()
- Label5.Text = "Current Directory:" & FTPDownloader.CurrentDirectory
- End Sub
- Private Sub ListFTPfiles_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListFTPfiles.SelectedIndexChanged
- Dim foldername As String = ListFTPfiles.SelectedItem
- If Not foldername.Contains(".") Then
- isFolder = True
- btnChangeDirectory.Enabled = True
- Else
- isFolder = False
- btnChangeDirectory.Enabled = False
- End If
- End Sub
- Private Sub btnUpdateServer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateServer.Click
- isUpdating = Not isUpdating
- If isUpdating Then
- UpdateServer(True)
- btnUpdateServer.Text = "Save Server Settings."
- ElseIf Not isUpdating Then
- UpdateServer(False)
- btnUpdateServer.Text = "Update Server"
- FTPDownloader.Hostname = TextBox1.Text.Trim
- FTPDownloader.Username = TextBox2.Text
- FTPDownloader.Password = TextBox3.Text
- End If
- End Sub
- Private Sub UpdateServer(ByVal isUpdate As Boolean)
- TextBox2.Enabled = isUpdate
- TextBox3.Enabled = isUpdate
- TextBox1.Enabled = isUpdate
- End Sub
- Private Sub bntUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bntUpload.Click
- Dim pathname As String
- Dim filename As String
- OpenFileDialog1.Title = "Upload"
- If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
- pathname = OpenFileDialog1.FileName
- filename = pathname.Substring(pathname.LastIndexOf("\") + 1)
- End If
- Try
- FTPDownloader.Upload(pathname, filename)
- Catch ex As Exception
- MessageBox.Show(ex.Message)
- RefreshList()
- End Try
- End Sub
- Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
- If ListFTPfiles.SelectedIndex <> -1 Then
- FTPDownloader.FtpDelete(ListFTPfiles.SelectedItem)
- Else
- MessageBox.Show("Please select a file!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
- End If
- End Sub
- Private Sub BcButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BcButton1.Click
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement