我有一个目录,其路径包含空格(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服务执行,因此我不能只选择用更现代的方式编写它。