我想在使用PowerShell的路徑開始處添加file://
。我怎樣才能做到這一點?我想是這樣的:使用PowerShell添加文件://在路徑的開始部分
$file = "C://Windows"
$path = Join-Path "file://" $file
但不工作。
我想在使用PowerShell的路徑開始處添加file://
。我怎樣才能做到這一點?我想是這樣的:使用PowerShell添加文件://在路徑的開始部分
$file = "C://Windows"
$path = Join-Path "file://" $file
但不工作。
$path = "file://" + $file
你也別需要逃避着在PowerShell中削減如此$file
可以$file="C:/Windows"
如果你真的想開放的語法,你可以利用的System.Uri,如:
[Uri]$tu = New-Object 'Uri'('C:\Windows');
write-host $tu.AbsoluteUri;
這將產生一個如下所示的URI輸出:
file:///C:/Windows
(是的,第三個'/'應該在文件後面:'。 RFC 1738指定有空間可選主機組件在uri中:file://<host>/<path>
)
this:'$ path =「file:// $ file」 – arco444