获取当前目录中的文件列表 [英] Getting list of files in current directory

查看:22
本文介绍了获取当前目录中的文件列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取一个脚本来读取脚本文件所在目录的内容,然后根据部分名称识别几个特定文件并对其进行压缩.但我无法让 object.Files 属性起作用.有人能告诉我这里出了什么问题吗?

I'm trying to get a script to read the contents of the directory where the script file is located, then identify a couple of specific files based on partial names and zip them. But I can't get the object.Files property to work. Can someone tell me what's wrong here?

Set FSO = CreateObject("Scripting.FileSystemObject")
objFolder = FSO.GetParentFolderName(WScript.ScriptFullName)
Set allFiles = objFolder.Files
For Each objFile in allFiles
    Wscript.Echo objFile.Name
Next

推荐答案

你的

objFolder = FSO.GetParentFolderName(WScript.ScriptFullName)

为 objFolder 分配一个路径(字符串)(检测到类型前缀欺诈!).使用

assigns a Path (String) to objFolder (type prefix fraud detected!). Use

Set objFolder = FSO.GetFolder(FSO.GetParentFolderName(WScript.ScriptFullName))

相反.

这篇关于获取当前目录中的文件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆