作者fumizuki (蒙面加菲狮)
看板Visual_Basic
标题Re: [VB6 ] 如何取得档案名称
时间Sat Jul 15 17:24:39 2006
※ 引述《halittle (靠山山倒靠人人倒)》之铭言:
: 找了好久的文
: 还是没有成功
: 如何把一资料夹里的档案名称 Ex: D:\ftp里的所有档案名称
: 全部取出到阵列
: 用DIR吗?
: 用个范例给我了解一下
: 谢谢^^
'自行准备一个 Command Button,名称=Command1
'以及一个 ListBox,名称=List1
Private Sub Command1_Click()
Dim el, Files
Files = GetFiles("D:\ftp")
List1.Clear
For Each el In Files
List1.AddItem el
Next
MsgBox "共找到" & (UBound(Files) + 1) & "个档案", vbInformation
End Sub
Public Function GetFiles(ByVal Path As String)
Const BufferSize As Integer = 32
Dim Files() As String, Index As Long, Length As Long
Length = BufferSize
ReDim Files(Length)
If Not Path Like "*\" Then Path = Path & "\"
Files(Index) = Dir(Path)
Do While Files(Index) <> ""
Index = Index + 1
If Index > Length Then
Length = Length + BufferSize
ReDim Preserve Files(Length)
End If
Files(Index) = Dir()
Loop
ReDim Preserve Files(Index)
GetFiles = Files
End Function
--
▃▅▇▆▄ ▆▂▃ `
逝去感情如何能留住,半点痴情遗留殊不易,██▅▇▄▃ ▇▃▂" .
█████████▃i ▁▄▇
更多凄凄惨惨的遭遇…………██▆▃ █▅▆▃ˍ▄*
◢ ▂█▄▇▅▂▌.
我不知道,王~八~蛋~~! ▂▆███ █▄▃ 。fumizuki。Check。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.184.116.195