一个简单的问题。欢迎大家来回答.

leoiv 2004-10-28 12:40:27
vb中如何判断一个目录是否为空?随便是函数还是语句实现.
...全文
87 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
江语 2004-10-28
关注,顶~~
回复
zhhot 2004-10-28
up!
回复
shanjuhua 2004-10-28
学习,谢谢。
回复
lxcc 2004-10-28
'引用Microsoft Scriptting Runtime
Dim fso As New FileSystemObject

Private Sub Command1_Click()
Dim fsoFolder As Folder
Set fsoFolder = fso.GetFolder("c:\test")
If fsoFolder.Size = 0 And fsoFolder.Files.Count = 0 And fsoFolder.SubFolders.Count = 0 Then
MsgBox "空文件夹"
Else
MsgBox "非空文件夹"
End If
End Sub
回复
jam021 2004-10-28
Private Sub Command1_Click()
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\FSO")
Dim i As Integer
i = 0
For Each f In objFolder.Files
i = i + 1
Next
If i = 0 Then
MsgBox "No file in this folder!"
End If
End Sub
回复
发帖
VB基础类
创建于2007-09-28

7479

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2004-10-28 12:40
社区公告
暂无公告