不用FSO,用API是否能列出指定目录下的文件或文件夹??到ListBox控件中用FSO是能做到,但觉得...呵呵.
如果不用,是否能做呢?用API可以不?
如果不用,是否能做呢?用API可以不?
解决方案 »
- vb程序中: Set itmX = List1.ListItems.Add(, , rs1.Fields(0)) 提示类型不配,为什么?急急急 代码如下
- 数组初始化
- 如果得到一个控件在窗体中的绝对位置?
- vb读excel,excel文件被改写吗?
- 高手in,帮我看一下这几行代码表示什么意思
- 请问如何设定某些功能在特定时间运行啊?? 急!! 在线等待
- 谁能帮我看看段查询代码到底出了什么问题!谢谢了!
- 一个很有挑战性的问题。
- 难题,请教一个变量的难题??
- 怎样在vb6里实现对flash4动画的显示
- 帮看下,通过PC发送短信的问题。
- QQ聊天室发言框中,为何无法使用SendMessage 的 WM_SETTEXT来发送一段字符。
'功 能:返回指定文件夹的所有文件夹列表
'返 回 值:成功/失败:True/False
'参 数:GetFileList(指定文件夹路径, 文件夹数组)
'引 用:无
'外部函数:无
'内部变量:[SearchDir=路径][FoundDir=文件夹名][i=用于循环]
'调用方法:
'++++++++++++++++++++++++++++++++++++
' Dim FolderName() As String, i As Long
' GetFolderList "C:\", FolderName
' For i = LBound(FolderName) To UBound(FolderName)
' Debug.Print FolderName(i)
' Next i
'++++++++++++++++++++++++++++++++++++
Public Function GetFolderList(ByVal Path As String, ByRef FolderName() As String) As Boolean
Dim SearchDir As String
Dim FoundDir As String
Dim i As Long
If right(Path, 1) <> "\" Then Path = Path & "\"
SearchDir = Path & "*."
FoundDir = Dir(SearchDir, vbDirectory)
While FoundDir <> ""
If Not FoundDir = "." Or FoundDir = ".." Then
ReDim Preserve FolderName(i) As String
FolderName(i) = FoundDir
End If
FoundDir = Dir()
i = i + 1
Wend
End Function'模 块 名:GetFileList
'功 能:返回指定文件夹的所有文件名列表
'返 回 值:成功/失败:True/False
'参 数:GetFileList(指定文件夹路径, 文件数组,返回的文件类型)
'引 用:无
'外部函数:无
'内部变量:[fName=文件名][i=用于循环]
'调用方法:
'++++++++++++++++++++++++++++++++++++
' Dim FileName() As String, i As Long
' GetFileList "c:\", FileName
' For i = 0 To UBound(FileName)
' Debug.Print FileName(i)
' Next i
'++++++++++++++++++++++++++++++++++++
Function GetFileList(ByVal Path As String, ByRef Filename() As String, Optional fExp As String = "*.*") As Boolean
Dim fName As String, i As Long
If right$(Path, 1) <> "\" Then Path = Path & "\"
fName = Dir$(Path & fExp)
i = 0
Do While fName <> ""
ReDim Preserve Filename(i) As String
Filename(i) = fName
fName = Dir$
i = i + 1
Loop
If i <> 0 Then
ReDim Preserve Filename(i - 1) As String
GetFileList = True
Else
GetFileList = False
End If
End Function
--------------
老问题了,看下FAQ啊。