Concatenate network path + variable
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
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