标签:style http color os strong 文件 io cti
//ListBox1.Items:= searchfile(‘Z:\‘);
//注意,path后面要有‘\‘;
function Searchfile(path:string):TStringList;
var
SearchRec:TSearchRec;
found:integer;
begin
Result:=TStringList.Create;
found:=FindFirst(path+‘*.*‘,faAnyFile,SearchRec);
while found=0 do
begin
if (SearchRec.Name<>‘.‘) and(SearchRec.Name<>‘..‘) and (SearchRec.Attr<>faDirectory) then
Result.Add(SearchRec.Name);
found:=FindNext(SearchRec);
end;
FindClose(SearchRec);
end;
//搜索1个文件下面的文件
// GetDirFiles (ListView1,‘Z:\aa\2013-06-23\‘);
procedure GetDirFiles(ListView:TListView;path: string;fileter:string=‘*.*‘);
var
SearchRec: TSearchRec;
found: integer;
begin
ListView.Items.Clear;
found := FindFirst(path + fileter, faAnyFile, SearchRec);
while found = 0 do
begin
if (SearchRec.Name <> ‘.‘) and (SearchRec.Name <> ‘..‘) and (SearchRec.Attr <> faDirectory) then
ListView.Items.Add.Caption:=SearchRec.Name;
found := FindNext(SearchRec);
end;
FindClose(SearchRec);
end;
上面一个只获取当前目录下所有文件,如果要获取该目录下的子目录的文件,看下面
Delphi获取目录下所有文件名,布布扣,bubuko.com
标签:style http color os strong 文件 io cti
原文地址:http://www.cnblogs.com/xe2011/p/3875841.html