标题: 紧急 求助! 高手 出来吧 拯救我~~~ [打印本页] 作者: lingxin5013 时间: 2008-7-24 17:00 标题: 紧急 求助! 高手 出来吧 拯救我~~~ 本人在F盘有N多个文件夹 不知道能否使用FSO得到文件夹的名称
或者有其它办法 在线等~~~~~
高手 出来救救 我吧作者: 假装不在 时间: 2008-7-24 17:11
输入命令行:
tree /f >c:/1.txt作者: 没有蛀牙 时间: 2008-7-24 17:16
Function ShowFolderList(folderspec)
Dim fs, f, f1, fc
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 in fc
ShowFolderList = ShowFolderList & f1.name
ShowFolderList = ShowFolderList & vbCrLf
Next
End Function
MsgBox ShowFolderList("F:\")作者: lingxin5013 时间: 2008-7-24 17:17
LS不好意思我没有描述清楚
你给我方法不错 但是不是我想要的,我想得到的就是如F盘下的所有文件夹名字,正常顺序排列就可以了,因为我要调用这些相关文件夹
仍然感谢!!!
能否在给点别的意见 谢谢作者: lingxin5013 时间: 2008-7-24 17:19
谢谢 2位帮忙 很猛啊你们! 作者: enjoytest 时间: 2008-7-24 17:59
感谢楼上的代码,发现LS的只能遍历下面一层的文件名,在此基础上稍加修改,使之能遍历全部,请试验一下,谢谢
' Definition of the function
Function ShowFolderList(folderspec)
Dim fs, f, f1, fc
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 in fc
ShowFolderList = ShowFolderList & f1.name
ShowFolderList = ShowFolderList & vbCrLf
MsgBox f1.name
ShowFolderList(folderspec+"\"+f1.name)
Next
' releae the resoure
Set fs = nothing
Set f = nothing
Set fc = nothing
End Function