连接网络路径 + 变量 [英] 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
谢谢
推荐答案
有几种方法.最简单的:
There are a couple of ways. The most simple:
$readfile = gc \\server01\folder01\$file
你的方法很接近:
$readfile = gc ("\\server01\folder01\" + $file)
您也可以使用 加入路径 例如:
You can also use Join-Path e.g.:
$path = Join-Path \\server01\folder01 $file
$readfile = gc $path
这篇关于连接网络路径 + 变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文