| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1200 人关注过本帖
标题:获取指定驱动器的所有目录
只看楼主 加入收藏
thiks
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2007-3-14
收藏
 问题点数:0 回复次数:11 
获取指定驱动器的所有目录
'Return all Folders from selected Drive.----------------------------------------
sPath$ = (sDriveLetter & "*.*") & Chr$(0)
'-------------------------------------------------------------------------------

'Search for First Folder Handle.------------------------------------------------
lReturn& = FindFirstFile(sPath$, WFD)
请大侠指教:获取指定驱动器的所有目录时驱动器名后加*.*是什么意思???
搜索更多相关主题的帖子: 驱动器 目录 获取 
2007-09-24 23:23
缘吇弹
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:地球
等 级:版主
威 望:43
帖 子:3038
专家分:27
注 册:2007-7-2
收藏
得分:0 
*为通配符

Repeat  Life=Study;Until (death);
2007-09-24 23:33
thiks
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2007-3-14
收藏
得分:0 

通配符是什么意思 *。*这又怎么理解?

2007-09-24 23:51
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
收藏
得分:0 

通配符.就是什么都能匹配.


我的msn: myfend@
2007-09-24 23:58
thiks
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2007-3-14
收藏
得分:0 
为什么搜索时驱动器名后加*.*
2007-09-25 00:09
雨中飞燕
Rank: 3Rank: 3
等 级:禁止访问
威 望:8
帖 子:2200
专家分:0
注 册:2007-8-9
收藏
得分:0 
不应该是*.*,如果是目录的话
2007-09-25 00:13
缘吇弹
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:地球
等 级:版主
威 望:43
帖 子:3038
专家分:27
注 册:2007-7-2
收藏
得分:0 
要是目录的话,那应该是啥?

Repeat  Life=Study;Until (death);
2007-09-25 00:14
thiks
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2007-3-14
收藏
得分:0 
还是小燕子厉害,是搜索目录,不过小弟不懂是为什么要加*.*
2007-09-25 00:22
thiks
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2007-3-14
收藏
得分:0 

Public Sub subShowFolderList(oFolderList As ListBox, oExplorerTree As TreeView, sDriveLetter As String, vParentID As Variant)

Dim nNode As Node 'Node object for ExplorerTree.
Dim lReturn As Long 'Holds Search Handle of File.
Dim lNextFile As Long 'Return Search Handle of next Folder.
Dim sPath As String 'Path to search.
Dim WFD As WIN32_FIND_DATA 'Win32 Structure (VB Type).
Dim sFolderName As String 'Name of Folder.
Dim x As Long 'Used to loop through Folders in frmMain.List1).

'Return all Folders from selected Drive.----------------------------------------
sPath$ = (sDriveLetter & "*.*") & Chr$(0)
'-------------------------------------------------------------------------------

'Search for First Folder Handle.------------------------------------------------
lReturn& = FindFirstFile(sPath$, WFD)
'-------------------------------------------------------------------------------

'Loop through all Folders (One level).------------------------------------------
Do

'If a Folder is found add to oFolderList.------------------------------------
If (WFD.dwFileAttributes And vbDirectory) Then

'Strip vbNullChar from Folder Name.-------------------------------------
sFolderName$ = mProcFunc.ftnStripNullChar(WFD.cFileName)
'-----------------------------------------------------------------------

If sFolderName$ <> "." And sFolderName$ <> ".." Then

'If the Folder has an Attribute <> 16 then add "~A~" to it.---------
If WFD.dwFileAttributes <> 16 Then
oFolderList.AddItem sFolderName$ & "~A~"
Else
oFolderList.AddItem sFolderName$ & "~~~"
End If
'-------------------------------------------------------------------

End If
End If
'---------------------------------------------------------------------------

'Search for Handle of next Folder.------------------------------------------
lNextFile& = FindNextFile(lReturn&, WFD)
'---------------------------------------------------------------------------

Loop Until lNextFile& = False
'-------------------------------------------------------------------------------

'Close Handle of Folder.--------------------------------------------------------
lNextFile& = FindClose(lReturn&)
'-------------------------------------------------------------------------------

'Loop through oFolderList which has it`s sorted property set to True, then add---
'Folder Path to ExplorerTree
For x = 0 To oFolderList.ListCount - 1

'If the Folder has an Attribute, set ForeColor to Grey----------------------
If Right(oFolderList.List(x), 3) = "~A~" Then
Set nNode = oExplorerTree.Nodes.Add(vParentID, tvwChild, , Left(oFolderList.List(x), Len(oFolderList.List(x)) - 3), "cldfoldera", "opnfoldera")
nNode.ForeColor = RGB(205, 205, 230)
Else
Set nNode = oExplorerTree.Nodes.Add(vParentID, tvwChild, , Left(oFolderList.List(x), Len(oFolderList.List(x)) - 3), "cldfolder", "opnfolder")
nNode.ForeColor = RGB(0, 0, 120)
End If
'---------------------------------------------------------------------------

Next x

'Clear frmMain.List1.-----------------------------------------------------------
oFolderList.Clear
'-------------------------------------------------------------------------------

End Sub

2007-09-25 00:26
雨中飞燕
Rank: 3Rank: 3
等 级:禁止访问
威 望:8
帖 子:2200
专家分:0
注 册:2007-8-9
收藏
得分:0 
我个人的理解是
"*.*"是所有有后缀名的文件,"*"是所有文件,包括无后缀和目录
其实你用VB的话直接用dir函数不是简单得多吗?用不着弄这个API啊
dir函数都封装好了
2007-09-25 00:28
快速回复:获取指定驱动器的所有目录
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015881 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved