VBS遍历文件或文件夹路径输入文件的所有绝对路径(附源码)

 更新时间:2019年12月08日 19:44:21   作者:Alter hu  
这篇文章主要介绍了VBS遍历文件或文件夹路径输入文件的所有绝对路径的代码,需要的朋友可以参考下
(福利推荐:【腾讯云】服务器最新限时优惠活动,云服务器1核2G仅99元/年、2核4G仅768元/3年,立即抢购>>>:9i0i.cn/qcloud

(福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun

源码如下:

Function listFilesPath(filepath)
  t1=Timer()
  Debug.WriteLine "****现在开始执行计数,用时:"+CStr(t1)
  Set fso=CreateObject("scripting.filesystemobject")
  Set myfolder=fso.GetFolder(filepath)
  If fso.FolderExists(filepath) then
    Set subcol=myfolder.SubFolders
    Set filescol=myfolder.Files
    For Each file In filescol
      Debug.WriteLine filepath+"\"+file.name
    Next
    If subcol.count>0 Then
      For Each folder In subcol
        'Debug.WriteLine filepath+"\"+folder.Name
        listFilesPath(filepath+"\"+folder.Name)
      next
      
    End if
  Else
    Debug.WriteLine "没有该文件系统"
  End if
  
  Set filescol=Nothing
  Set subcol=nothing
  Set fso=Nothing
  t2=Timer()
Debug.WriteLine "****现在完成计数,用时:"+CStr(t2)
Debug.WriteLine "整个操作过程用时:"&CStr(t2-t1)&" 秒"
End function

之前程序员之家小编更新过类似的文章,大家可以参考一下

相关文章

最新评论

?


http://www.vxiaotou.com