我正在尝试验证文件的存在,但问题是文件名中包含方括号,即 c:\test[R] 10005404,注释失败,[S] SiteName.txt。
我尝试使用字符串 .replace 方法但没有成功。
$a = c:\test\[R] 10005404, Failed with Comments, [S] SiteName.txt
$Result = (Test-Path $a)
# Returns $False even though the file exists.
试过了
$a = $a.Replace("[", "`[")
$a = $a.Replace("]", "`]")
$Result = (Test-Path $a)
# Also returns $False even though the file exists.
想法将不胜感激。谢谢,克里斯M