我试图验证文件的存在,但问题是文件名在名称中有括号,即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.
Run Code Online (Sandbox Code Playgroud)
$a = $a.Replace("[", "`[")
$a = $a.Replace("]", "`]")
$Result = (Test-Path $a)
# Also returns $False even though the file exists.
Run Code Online (Sandbox Code Playgroud)
想法将不胜感激.谢谢,ChrisM