51Testing软件测试论坛

标题: 紧急 求助! 高手 出来吧 拯救我~~~  [打印本页]

作者: 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

' call the function
ShowFolderList("C:\temp")

欢迎批评指正,呵呵 
作者: enjoytest    时间: 2008-7-24 18:04
才发现又加了两层,呵呵
再附加说明一下
1.可将MsgBox   f1.name 改为直接写入文件中
2.将C:\temp处路径改成你的目标路径即可
作者: maihua258    时间: 2008-7-25 10:33
可是你们从哪里编写再执行这个代码达到目的呢?关注。。。。。。
作者: lingxin5013    时间: 2008-7-25 10:39
呵呵 我现在的项目会随即创建一个语音文件,自动保存到指定的目录下并且在源文件中可以看到相关的保存路径.因为文件夹自动取名为地址名称,由于文件夹数量比较多有400多个我全部要取出把这个地址付在相应的URL后面,然后使用LR调用进行性能测试.呵呵




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2