我有一个包含大量相关内容的散列,一件事是日志文件的“句柄”:
$myHash = NewObject psobject -Property @{
# ...
"LogFile" = [System.IO.StreamWriter] $($Env:USERPROFILE+"\Documents\Logs\MsgLog.txt")
# ...
}这在(我的翻译)中失败了:值“C:\Users.”不能转换为"System.IO.StreamWriter“
路径是有效的。
我要换什么?
提前感谢
古利
发布于 2014-06-16 22:35:37
试着这样做:
$myHash = New-Object psobject -Property @{
# ...
LogFile = new-object System.IO.StreamWriter "$($Env:USERPROFILE)\Documents\Logs\MsgLog.txt"
# ...}
注意:除非您在键/属性名称中添加空格,否则不必引用它们。
https://stackoverflow.com/questions/24248916
复制相似问题