-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.vb
134 lines (131 loc) · 4.74 KB
/
main.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
Public Class Form1
Dim Thread1, Thread2, Thread3 As System.Threading.Thread
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.CheckForIllegalCrossThreadCalls = False
End Sub
Private Sub CheckProgress()
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub Search()
Dim MainFolder = BrowsePathText.Text
If MainFolder = "" Then
MsgBox("Please Choose Directory")
flpath = " "
ListBox1.Items.Clear()
Else
Dim FolderInfo As New System.IO.DirectoryInfo(MainFolder)
Files = FolderInfo.GetFiles("*" & SearchText.Text & "*.*",
IO.SearchOption.AllDirectories)
For Each Results In Files
flpath = " "
flpath = Results.Name
ListBox1.Items.Add(flpath)
Next
Timer1.Enabled = False
If ListBox1.Items.Count() = 0 Then
MsgBox("No Result Found")
End If
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Timer1.Enabled = True
CheckProgress()
Thread1 = New System.Threading.Thread(AddressOf Search)
Thread1.Start()
Timer1.Enabled = False
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Timer1.Enabled = True
Dim NewFolder As System.IO.DirectoryInfo = New System.IO.DirectoryInfo(BrowsePathText.Text + "\" + SearchText.Text)
Dim Items = ListBox1.Items.Count()
If NewFolder.Exists Then
MsgBox("Folder Already Created")
For Each number As String In ListBox1.Items
Dim check As System.IO.DirectoryInfo = New System.IO.DirectoryInfo(BrowsePathText.Text + "\" + SearchText.Text + "\" + ListBox1.GetItemText(number))
If check.Exists Then
MsgBox("Files Already In It")
Else
Try
System.IO.File.Move(BrowsePathText.Text + "\" + ListBox1.GetItemText(number), BrowsePathText.Text + "\" + SearchText.Text + "\" + ListBox1.GetItemText(number))
Catch damn As System.IO.FileNotFoundException
Form2.Show()
Form2.Close()
End Try
End If
Next
MsgBox("Folder Created " & "Files are moved", MsgBoxStyle.Information)
Else
NewFolder.Create()
For Each number As String In ListBox1.Items
Dim check As System.IO.DirectoryInfo = New System.IO.DirectoryInfo(BrowsePathText.Text + "\" + SearchText.Text + "\" +
ListBox1.GetItemText(number))
If check.Exists Then
MsgBox("Files Already In It")
Else
Try
System.IO.File.Move(BrowsePathText.Text + "\" + ListBox1.GetItemText(number), BrowsePathText.Text + "\" + SearchText.Text + "\" + ListBox1.GetItemText(number))
Catch damn As System.IO.FileNotFoundException
Form2.Show()
Form2.Close()
End Try
End If
Next
MsgBox("Folder Created " & "Files are moved", MsgBoxStyle.Information)
End If
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs)
Handles ListBox1.SelectedIndexChanged
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles
SearchText.TextChanged
End Sub
Private Sub FolderBrowserDialog1_HelpRequest(sender As Object, e As EventArgs)
Handles FolderBrowserDialog1.HelpRequest
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
If (FolderBrowserDialog1.ShowDialog() = DialogResult.OK) Then
BrowsePathText.Text = FolderBrowserDialog1.SelectedPath
End If
End Sub
Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs)
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles
Button5.Click
Thread3 = New System.Threading.Thread(AddressOf Close)
Thread3.Start()
End Sub
Public Sub BrowsePathText_TextChanged(sender As Object, e As EventArgs) Handles
BrowsePathText.TextChanged
End Sub
Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click
End Sub
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
End Sub
Private Sub Timer1_Tick_1(sender As Object, e As EventArgs) Handles Timer1.Tick
End Sub
Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles
Button7.Click
ListBox1.Items.Clear()
SearchText.Clear()
ProgressBar1.Value = 0
End Sub
Private Sub ProgressBar1_Click(sender As Object, e As EventArgs) Handles
ProgressBar1.Click
End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object, e As
System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
If Timer1.Enabled = True Then
ProgressBar1.Increment(5)
Else
ProgressBar1.Value = 100
End If
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As
System.ComponentModel.RunWorkerCompletedEventArgs) Handles
BackgroundWorker1.RunWorkerCompleted
ProgressBar1.Value = 100
End Sub
End Class