【发布时间】:2013-05-03 09:15:12
【问题描述】:
我的 INI (config.ini) 文件如下所示
#this is comment
[Folder]
C:\temp
C:\dir1
C:\dir2
如何使用powershell获取[Folder]的内容?
我需要数组中的文件夹路径
我看到的例子是名称值对
【问题讨论】:
标签: powershell
我的 INI (config.ini) 文件如下所示
#this is comment
[Folder]
C:\temp
C:\dir1
C:\dir2
如何使用powershell获取[Folder]的内容?
我需要数组中的文件夹路径
我看到的例子是名称值对
【问题讨论】:
标签: powershell
使用您的示例 config.ini:
[System.Collections.ArrayList]$a = GC .\CONFIG.INI
[string[]]$b=$a.GetRange( $a.IndexOf("[Folder]")+1, ( $a.Count - ($a.IndexOf("[Folder]")+1)))
$b
C:\temp
C:\dir1
C:\dir2
【讨论】:
[xxxxx] 它将失败。现在我只需要一个。因此接受这个答案。感谢您的宝贵时间
($a.IndexOf("[Folder]")+1, ( $a.IndexOf("[xxxx]") - $a.indexof("[Folder]")))修复范围@