如何用VB搜索计算机存在的cs1.6这个文件夹,不知道具体位置,可能D盘或E盘

来源:百度知道 编辑:UC知道 时间:2024/07/01 04:07:00
最好能将这个文件复制到F盘

'在窗体上加入控件command1,然后在代码区复制下面代码,并稍加修改,运行,即可得到结果。
'====窗体代码====
Option Explicit

'通过查找函数,请不要修改
Public Function scan(a As String, zfc As String) As String
Dim filename As String
Dim nd As Integer
Dim fold() As String
Dim n As Integer, Tmp As String
If Right(a, 1) <> "\" Then a = a & "\"
filename = Dir(a, vbDirectory)
Do While filename <> ""
If filename <> "." And filename <> ".." Then
If GetAttr(a & filename) = vbDirectory Then
nd = nd + 1
ReDim Preserve fold(nd)
fold(nd) = a & filename
'List1.AddItem fold(nd)
If LCase(filename) = LCase(zfc) Then
scan = fold(nd)
Exit Function
End If
End If
End If
filename = Dir
DoEvents
Loop
For n = 1 To nd