vbscript - FileSystemObject.FolderExists 被文件名中的空格破坏
问题描述
我有一个目录,其路径包含空格 ( C:\foo bar\
)。目录存在。
我可以打开命令提示符并执行以下操作:
cd "C:\foo bar\"
我的当前目录按预期更改为该目录。
在 VBS 中,我这样做:
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
Dim path: path = "C:\foo bar\"
If Not fso.FolderExists(Chr(34) & path & Chr(34)) Then
MsgBox "escaped path doesn't exist"
End If
If Not fso.FolderExists(path) Then
MsgBox "unquoted it's still not found!"
End If
...并且我在脚本运行时看到了弹出对话框,但不应该。
它似乎也导致该MoveFile
功能出现问题。
这个 VBS 脚本是由 VB6 服务执行的,所以我不能选择用更现代的方式来编写它。
解决方案
推荐阅读
- qt - QT。qt中的点图
- python - 使用 pandas 从同一工作簿中的多个 Excel 工作表中提取部分数据
- php - 在条件下获取子字符串
- python - SQLite 只从数据库中查询特定的东西
- html - 具有一个可滚动列的两列页面因连续滚动而卡住
- regex - 正则表达式如何查找以“TcxGridDBBandedColumn”开头、以“end”结尾且内部不包含“Width”的行块
- android - BottomNavigationView:设置圆形图像并获取视图参考
- .net - 为什么在浏览器 > 开发工具 > 网络中的 Blazor WebAssembly 应用程序上看不到 DLL 和 dotnet.wasm?
- file - 如何将 NTFS 元数据添加到任何文件?
- r - 儒略日期到带有小数的R中的日历日期