用户登录
用户注册

分享至

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

  • 作者: 夏日友人帐
  • 来源: 51数据库
  • 2021-07-08

源码如下:

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

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

软件
前端设计
程序设计
Java相关