[英]mkdir path error - Trying to concatenate strings
I am trying to just make a directory, but I cannot figure it out. 我试图建立一个目录,但无法弄清楚。 I am trying to make a template so I want everything in the program to reference the form name. 我正在尝试制作一个模板,所以我希望程序中的所有内容都引用表单名称。 I am using Powershell Studio to write this program. 我正在使用Powershell Studio编写此程序。
This does not work (Desired method): 这不起作用(所需方法):
$FormName = $formChangeMe.Text | out-string
$PATHDIR = ($env:USERPROFILE + "\AppData\Local\Tools\" + $FormName)
md -Force $PATHDIR
Output from $PATHDIR
returns C:\\Users\\Username\\AppData\\Local\\Tools\\ChangeMe
but it wont make the directory. $PATHDIR
输出返回C:\\Users\\Username\\AppData\\Local\\Tools\\ChangeMe
但不会创建目录。
This does work: 这确实有效:
$PATHDIR = "C:\Users\Username\AppData\Local\Tools\ChangeMe"
md -Force $PATHDIR
I cant see why the one works and the other doesn't. 我看不出为什么一个有效而另一个无效。 I don't think I understand when to use ()
vs ''
vs ""
. 我不认为我了解什么时候使用()
VS ''
VS ""
。
$FormName = ($formChangeMe.Text | out-string).Trim()
-感谢Matt!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.