Coba by Liudi90

VIEWS: 497 PAGES: 2

									   C:\Users\Liudi\Documents\Visual Studio 2008\Projects\Files\Files\Form1.vb          1
 1 Imports System.IO
 2
 3 Public Class Form1
 4
 5     Sub New()
 6          InitializeComponent()
 7          Me.ToolStrip1.GripStyle = ToolStripGripStyle.Hidden
 8          Me.tspAllFolder.Items.Add("True")
 9          Me.tspAllFolder.Items.Add("False")
10          Me.tspAllFolder.SelectedIndex = 1
11          Me.tspAllFolder.DropDownStyle = ComboBoxStyle.DropDownList
12          Dim aaa() As String = {"*.txt", "*.jpg", "*.pdf", "*.mp3", "*.exe"}
13          Me.tspFilter.Items.AddRange(aaa)
14          Me.tspFilter.SelectedIndex = -1
15          Me.tspFilter.DropDownStyle = ComboBoxStyle.DropDown
16          Me.ToolStripStatusLabel1.Text = "Banyak Baris = " & Me.RichTextBox1.Lines.
       Length.ToString("#,##0") & _
17          " | Jumlah Karakter = " & Me.RichTextBox1.TextLength.ToString("#,##0")
18     End Sub
19
20     Private Sub tspBrowse_Click(ByVal sender As System.Object, ByVal e As System.
       EventArgs) Handles tspBrowse.Click
21          Try
22              Using fbd As New FolderBrowserDialog
23                  With fbd
24                       .Description = "Tentukan Folder Untuk Mendapatkan Semua File
       dalam Folder tersebut."
25                       .ShowNewFolderButton = False
26                       .RootFolder = Environment.SpecialFolder.Desktop
27                       .SelectedPath = My.Computer.FileSystem.SpecialDirectories.
       MyDocuments
28                       If .ShowDialog = Windows.Forms.DialogResult.OK Then
29                           Me.tspAlamat.Text = .SelectedPath
30                       End If
31                  End With
32              End Using
33          Catch ex As Exception
34              MessageBox.Show(ex.Message, "Error In Method Browse", MessageBoxButtons
       .OK, MessageBoxIcon.Error)
35          End Try
36     End Sub
37
38     Private Sub tspGetFiles_Click(ByVal sender As System.Object, ByVal e As System.
       EventArgs) Handles tspGetFiles.Click
39          Try
40              If tspAlamat.Text <> String.Empty Then
41                  Me.RichTextBox1.Clear()
42                  Dim BrowseAll As Integer, filter As String
43                  If tspAllFolder.SelectedIndex = 1 Then BrowseAll = 2 Else BrowseAll
        = 3
44                  If tspFilter.Text = "" Then filter = "*.*" Else filter = tspFilter.
       Text.Trim
45                  For Each xxx As String In My.Computer.FileSystem.GetFiles(Me.
       tspAlamat.Text, CType(BrowseAll, FileIO.SearchOption), filter)
46                       Dim aaa As New FileInfo(xxx)
47                       Me.RichTextBox1.AppendText(String.Format("{0};{1};{2};{3}{4}",
       aaa.Name, aaa.Length, aaa.FullName, _
48 aaa.CreationTime.Date.ToString("yyyy/MM/dd"), vbNewLine))
49                  Next
50                  Me.ToolStripStatusLabel1.Text = "Banyak Baris = " & Me.RichTextBox1
       .Lines.Length.ToString("#,##0") & _
51                  " | Jumlah Karakter = " & Me.RichTextBox1.TextLength.ToString("#,##
       0")
52              End If
53          Catch ex As Exception
54              MessageBox.Show(ex.Message, "Error In Method GetFiles",
       MessageBoxButtons.OK, MessageBoxIcon.Error)
55          End Try
56     End Sub
57
58     Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
       System.EventArgs) Handles RichTextBox1.TextChanged
     C:\Users\Liudi\Documents\Visual Studio 2008\Projects\Files\Files\Form1.vb            2
59           Try
60               Me.ToolStripStatusLabel1.Text = "Banyak Baris = " & Me.RichTextBox1.
         Lines.Length.ToString("#,##0") & _
61               " | Jumlah Karakter = " & Me.RichTextBox1.TextLength.ToString("#,##0")
62           Catch ex As Exception
63               MessageBox.Show(ex.Message, "Error In Method Rtf_TextChanged",
         MessageBoxButtons.OK, MessageBoxIcon.Error)
64           End Try
65       End Sub
66
67       Private Sub tsbSave_Click(ByVal sender As System.Object, ByVal e As System.
         EventArgs) Handles tsbSave.Click
68           Try
69               Me.RichTextBox1.SaveFile(My.Computer.FileSystem.SpecialDirectories.
         Desktop & "\GetFiles.txt", RichTextBoxStreamType.PlainText)
70               System.Diagnostics.Process.Start(My.Computer.FileSystem.
         SpecialDirectories.Desktop & "\GetFiles.txt")
71           Catch ex As Exception
72               MessageBox.Show(ex.Message, "Error In Method Save", MessageBoxButtons.
         OK, MessageBoxIcon.Error)
73           End Try
74       End Sub
75
76       Private Sub tspReset_Click(ByVal sender As System.Object, ByVal e As System.
         EventArgs) Handles tspReset.Click
77           Try
78               Me.RichTextBox1.Clear()
79               Me.tspAlamat.Clear()
80               Me.tspFilter.SelectedIndex = -1
81               Me.tspAllFolder.SelectedIndex = 1
82           Catch ex As Exception
83               MessageBox.Show(ex.Message, "Error In Method Clear", MessageBoxButtons.
         OK, MessageBoxIcon.Error)
84           End Try
85       End Sub
86
87 End Class
88

								
To top