简体   繁体   English

连接网络路径+变量

[英]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 eg:您还可以使用Join-Path例如:

$path = Join-Path \\server01\folder01 $file
$readfile = gc $path

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM