所以我有这段代码:
$userprofile=Get-ChildItem Env:USERPROFILE
$localpath="$userprofile\some\path"
我希望从$localpath
输出以下内容:
c:\users\username\some\path
但我得到的是:
System.Collections.DictionaryEntry\some\path
因此,当然,cd $localpath
之类的东西失败了。我如何实现我的需求?
答案 0 :(得分:11)
获取字符串值而不是字典条目(在技术上是 for case let rowView in self.tableView.subviews {
for case let tableviewCell as ContactInfoTableViewCell in rowView.subviews {
tableviewCell.contactValue.resignFirstResponder()
}
}
正在访问的)的一种简便方法是使用变量语法:Get-ChildItem
而不是$Env:USERPROFILE
。
Get-ChildItem Env:USERPROFILE
了解更多信息:
PowerShell Environment Provider
此外,Join-Path
cmdlet是组合路径的两个部分的好方法。
$localpath = "$env:USERPROFILE\some\path"