【发布时间】:2017-09-21 10:05:05
【问题描述】:
我希望从包含多个存储路径的字符串中删除最后一个“/”字符,最好的方法是什么,我一直在接近,但我仍然无法完全理解我想要的正在寻找,循环真的是唯一的方法吗?
$Paths = /some/path/1/ /some/path/2/ /some/path/3/
$Paths = $Paths.Remove($Paths.Length - 1)
$Index = $Paths.LastIndexOf('/')
$ID = $Paths.Substring($Index + 1)
我目前遇到如下错误:
Exception calling "Remove" with "1" argument(s): "Collection was of a fixed size."
所需的 $Paths 最终版本是
/some/path/1 /some/path/2 /some/path/3
任何帮助将不胜感激,我想我可能有流程问题以及编码问题...
【问题讨论】:
标签: powershell