【发布时间】:2017-07-14 19:04:45
【问题描述】:
我想在\ 的反斜杠处拆分两条路径,并用斜杠/ 将它们连接起来。
但我收到一个错误,提示我没有该文件夹的权限,但我有管理员权限。
$PathOne = C:\example\example
$PathTwo = C:\example\example
$PathOne
$PathOne $PathOne("\")
(Get-Content $PathTwo) -Join ("/")
$$PathTwo = $NewPath
$$PathTwo -Split("\")
(Get-Content $PathTwo) -Join ("/")
错误是用“/”加入。
完整的错误代码: + FullyQualifiedErrorId : GetContentReaderUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetContentCommand
【问题讨论】:
-
您能否编辑问题并显示您想要达到的具体目标?添加任何错误消息和产生错误的实际命令。
-
$PathOne $$PathOne("\")的目标是什么?最后一个标记$$运算符在这里是一个奇怪的构造,因此缺少对变量的赋值和使用 Get-Content 来做什么,呃,什么? -
你只是想把
C:\example\example变成C:/example/example吗?如果是这样$NewPathOne = $PathOne.Replace('\','/') -
是的,詹姆斯,我想这样做,谢谢它有效
-
很高兴我能提供帮助,如果您对我的回答感到满意,您可以Mark it as Accepted。
标签: powershell