Advertisement
Guest User

Untitled

a guest
Oct 4th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 4.80 KB | None | 0 0
  1. Public Class Form1
  2.     Private FTPDownloader As New Utilities.FTP.FTPclient
  3.     Private isFolder As Boolean = False
  4.     Private isUpdating As Boolean = False
  5.  
  6.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  7.         btnChangeDirectory.Enabled = False
  8.         FTPDownloader.Hostname = TextBox1.Text.Trim
  9.         FTPDownloader.Username = TextBox2.Text
  10.         FTPDownloader.Password = TextBox3.Text
  11.  
  12.     End Sub
  13.     'ADD BRUTEFORCER AND PROXY SUPPORT
  14.     Private Sub btnHomeDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHomeDir.Click
  15.         FTPDownloader.CurrentDirectory = "/"
  16.         RefreshList()
  17.         UpdateDirectoryLabel()
  18.     End Sub
  19.  
  20.     Private Sub RefreshList()
  21.         ListFTPfiles.Items.Clear()
  22.         Try
  23.             For Each File In FTPDownloader.ListDirectoryDetail
  24.                 ListFTPfiles.Items.Add(File.Filename)
  25.  
  26.             Next
  27.         Catch ex As Exception
  28.             MessageBox.Show(ex.Message)
  29.         End Try
  30.  
  31.     End Sub
  32.  
  33.     Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownload.Click
  34.         If ListFTPfiles.SelectedIndex <> -1 Then
  35.  
  36.  
  37.             If MessageBox.Show("Would you like to download" & ListFTPfiles.SelectedItem, "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
  38.                 FTPDownloader.Download(ListFTPfiles.SelectedItem, My.Computer.FileSystem.SpecialDirectories.MyDocuments + "\" + ListFTPfiles.SelectedItem, True)
  39.                 MessageBox.Show("The file has been downloaded to My Documents", "Download Finished!", MessageBoxButtons.OK, MessageBoxIcon.Information)
  40.             Else
  41.                 MessageBox.Show("Download aborted", "Download Aborted", MessageBoxButtons.OK, MessageBoxIcon.Information)
  42.  
  43.             End If
  44.         Else
  45.             MessageBox.Show("Please select a file!", "Select a file.", MessageBoxButtons.OK, MessageBoxIcon.Information)
  46.         End If
  47.  
  48.     End Sub
  49.  
  50.     Private Sub btnChangeDirectory_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChangeDirectory.Click
  51.         FTPDownloader.CurrentDirectory += ListFTPfiles.SelectedItem + "/"
  52.         RefreshList()
  53.         UpdateDirectoryLabel()
  54.     End Sub
  55.  
  56.     Private Sub UpdateDirectoryLabel()
  57.         Label5.Text = "Current Directory:" & FTPDownloader.CurrentDirectory
  58.  
  59.     End Sub
  60.  
  61.     Private Sub ListFTPfiles_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListFTPfiles.SelectedIndexChanged
  62.         Dim foldername As String = ListFTPfiles.SelectedItem
  63.         If Not foldername.Contains(".") Then
  64.             isFolder = True
  65.             btnChangeDirectory.Enabled = True
  66.         Else
  67.             isFolder = False
  68.             btnChangeDirectory.Enabled = False
  69.         End If
  70.     End Sub
  71.  
  72.     Private Sub btnUpdateServer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateServer.Click
  73.         isUpdating = Not isUpdating
  74.         If isUpdating Then
  75.             UpdateServer(True)
  76.             btnUpdateServer.Text = "Save Server Settings."
  77.         ElseIf Not isUpdating Then
  78.             UpdateServer(False)
  79.             btnUpdateServer.Text = "Update Server"
  80.             FTPDownloader.Hostname = TextBox1.Text.Trim
  81.             FTPDownloader.Username = TextBox2.Text
  82.             FTPDownloader.Password = TextBox3.Text
  83.  
  84.         End If
  85.  
  86.  
  87.     End Sub
  88.     Private Sub UpdateServer(ByVal isUpdate As Boolean)
  89.         TextBox2.Enabled = isUpdate
  90.         TextBox3.Enabled = isUpdate
  91.         TextBox1.Enabled = isUpdate
  92.     End Sub
  93.  
  94.     Private Sub bntUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bntUpload.Click
  95.         Dim pathname As String
  96.         Dim filename As String
  97.         OpenFileDialog1.Title = "Upload"
  98.         If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
  99.             pathname = OpenFileDialog1.FileName
  100.             filename = pathname.Substring(pathname.LastIndexOf("\") + 1)
  101.         End If
  102.         Try
  103.             FTPDownloader.Upload(pathname, filename)
  104.  
  105.         Catch ex As Exception
  106.             MessageBox.Show(ex.Message)
  107.             RefreshList()
  108.  
  109.         End Try
  110.     End Sub
  111.  
  112.     Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
  113.         If ListFTPfiles.SelectedIndex <> -1 Then
  114.             FTPDownloader.FtpDelete(ListFTPfiles.SelectedItem)
  115.         Else
  116.             MessageBox.Show("Please select a file!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  117.  
  118.         End If
  119.     End Sub
  120.  
  121.     Private Sub BcButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BcButton1.Click
  122.    
  123.  
  124.     End Sub
  125. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement