Reputation: 2215
How can I concatenate this path with this variable?
$file = "My file 01.txt" #The file name contains spaces
$readfile = gc "\\server01\folder01\" + ($file) #It doesn't work
Thanks
Upvotes: 65
Views: 121134
Reputation: 201972
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
Upvotes: 102