练习了一下,是这样吗?用VB6的思路去写的~
顺道问一下~这样写好像FileListBox1的反应不是很灵敏~
这是为何?

程序代码:
Option Explicit On
Public Class Form1
Dim FileList() As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim TempString As String, FilePath As String, SmailarFile As String, Temp() As String, Target As String
Dim i As Short, j As Object
ReDim FileList(0)
If TextBox1.Text <> "" Then
Target = Trim(InputBox("The Target File Path is ..."))
If Target <> "" Then
Target = IIf(Mid(Target, Len(Target), 1) = "\", Target, Target & "\")
TempString = Trim(TextBox1.Text) : ToolTip1.SetToolTip(TextBox1, TempString)
If InStr(TempString, ":") <> 0 And InStr(TempString, "\") <> 0 And InStr(TempString, ".") <> 0 Then
Temp = Split(TempString, "\")
DriveListBox1.Drive = Temp(0)
If UBound(Temp) > 2 Then
For i = 0 To UBound(Temp) - 1
FilePath = FilePath & Temp(i) & "\"
Next i
DirListBox1.Path = FilePath
Else
DirListBox1.Path = Temp(0) & "\"
End If
SmailarFile = Mid(Temp(UBound(Temp)), 1, InStr(Temp(UBound(Temp)), ".") - 1)
FileListBox1.Pattern = "*.*"
FileListBox1.Path = FilePath
i = 0 : ListBox1.Items.Clear()
For Each j In FileListBox1.Items
If InStr(j, SmailarFile) <> 0 Then
ReDim Preserve FileList(i)
FileList(i) = FilePath & j
ListBox1.Items.Add(j)
i += 1
End If
Next j
For i = 0 To UBound(FileList)
FileCopy(FileList(i), Target & Mid(FileList(i), InStrRev(FileList(i), "\") + 1))
Next i
'MessageBox.Show(Join(FileList, vbNewLine))
Else
MessageBox.Show("Input File Path Format Error !", "ERROR")
TextBox1.Text = "" : ListBox1.Items.Clear()
End If
Else
MessageBox.Show("No Target Path !", "ERROR")
End If
Else
MessageBox.Show("No Data !", "ERROR")
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox1.Text = "" : ListBox1.Items.Clear()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Application.Exit()
End Sub
Private Sub DriveListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DriveListBox1.SelectedIndexChanged
DirListBox1.Path = DriveListBox1.Drive
FileListBox1.Path = DirListBox1.Path
End Sub
Private Sub DirListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DirListBox1.SelectedIndexChanged
FileListBox1.Items.Clear()
FileListBox1.Path = DirListBox1.Path
End Sub
End Class