更新时间:2023-02-23 18:32:08
Doing $woo + $hoo
does not return the proper filepath:
PS > $woo = "c:\temp"
PS > $hoo = "shabang"
PS > $woo + $hoo
c:\tempshabang
PS >
Instead, you should use the Join-Path
cmdlet to concatenate $woo
and $hoo
:
New-Item -ItemType File (Join-Path $woo $hoo)
See a demonstration below:
PS > $woo = "c:\temp"
PS > $hoo = "shabang"
PS > Join-Path $woo $hoo
c:\temp\shabang
PS >