62

このパスをこの変数と連結するにはどうすればよいですか?

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

$readfile = gc "\\server01\folder01\" + ($file) #It doesn't work

ありがとう

4

1 に答える 1

97

いくつかの方法があります。最も単純なもの:

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

あなたのアプローチは近かった:

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

Join-Pathを使用することもできます。

$path = Join-Path \\server01\folder01 $file
$readfile = gc $path
于 2012-12-09T01:43:30.380 に答える