首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

怎么把ini文件中一个键值下的所有分支内容读到ListBox1中

2012-02-08 
如何把ini文件中一个键值下的所有分支内容读到ListBox1中?FileCopy.ini文件中的内容:[FilePath]Path0D:\

如何把ini文件中一个键值下的所有分支内容读到ListBox1中?
FileCopy.ini文件中的内容:
[FilePath]
Path0=D:\新建文件夹
Path1=D:\五笔安装
...


如何把
D:\新建文件夹
D:\五笔安装
...
读到ListBox1中?

[解决办法]
var
Keys:TStringList;
ini:TIniFile;
i:Integer;
begin
Keys:=TStringList.Create;
Ini:=TIniFile.Create( 'FileCopy.ini路径 ');
Ini.ReadSection( 'FilePath ',Keys);
for i:=0 to Keys.Items.Count-1 do
begin
ListBox1.Items.Add(Ini.ReadString( 'FilePath ',Keys.String[i], ' ');
end;
Ini.Free;
Keys.Free;
end;

//代码自己测试
[解决办法]
或者你用一个Key保存路径数也可以

热点排行