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

'Search for First Folder Handle.------------------------------------------------
lReturn& = FindFirstFile(sPath$, WFD)
请大侠指教:获取指定驱动器的所有目录时驱动器名后加*.*是什么意思???
搜索更多相关主题的帖子: 驱动器 目录 获取 
2007-09-24 23:23
thiks
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2007-3-14
收藏
得分:0 

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

2007-09-24 23:51
thiks
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2007-3-14
收藏
得分:0 
为什么搜索时驱动器名后加*.*
2007-09-25 00:09
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
thiks
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2007-3-14
收藏
得分:0 
我是边打工边自学,没人教,看到啥学啥!
谢谢
2007-09-25 00:41
快速回复:获取指定驱动器的所有目录
数据加载中...
 
   



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

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