且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何合并用于创建和删除的路径和文件名

更新时间: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 >