用ListView控件列举指定目录中的文件,以列举C盘文件目录为例子:
procedure TForm1.Button1Click(Sender: TObject);
var
SearchRec : TSearchRec;
Path : String;
Attr : integer;
Found : integer;
begin
Path := 'c:\*.*';//设定要显示的路径
Attr := faAnyFile;
Found := FindFirst(Path, Attr, SearchRec);//查找文件
while Found = 0 do
begin
ListView1.Items.Add; //添加内容
ListView1.Items[ListView1.Items.Count-1].Caption := (SearchRec.Name);
Found := FindNext(SearchRec);
end;
FindClose(SearchRec);//停止查找
end;
欢迎访问最专业的网吧论坛,无盘论坛,网吧经营,网咖管理,网吧专业论坛
https://bbs.txwb.com
关注天下网吧微信/下载天下网吧APP/天下网吧小程序,一起来超精彩
|
本文来源:学Delphi 作者:佚名