Concatenate network path + variable

后端 未结 1 886
醉酒成梦
醉酒成梦 2020-12-30 18:20

How can I concatenate this path with this variable?

$file = \"My file 01.txt\" #The file name contains spaces

$readfile = gc \"\\\\server01\\folder01\\\" +          


        
相关标签:
1条回答
  • 2020-12-30 19:10

    There are a couple of ways. The most simple:

    $readfile = gc \\server01\folder01\$file
    

    Your approach was close:

    $readfile = gc ("\\server01\folder01\" + $file)
    

    You can also use Join-Path e.g.:

    $path = Join-Path \\server01\folder01 $file
    $readfile = gc $path
    
    0 讨论(0)
提交回复
热议问题