转载:<br>具体到每一个文件的属性,你可以自己修改getfilelist函数,<br>function GetFileList(path:string;Attr:integer;FileList:TStringList):boolean;<br>var<br> SearchRec: TSearchRec;<br> i,total:integer;<br>begin<br> i:=FindFirst(path, attr, SearchRec);<br> if i <> 0 then<br> begin<br> result := false;<br> exit;<br> end;<br> while i = 0 do<br> begin<br> //FileList.Add(SearchRec.Name);<br> total:=SearchRec.size<br> i:=FindNext(SearchRec);<br> end;<br> FindClose(SearchRec);<br> result := true;<br>end;<br><br>使用范例:<br>var<br> FileList:Tstringlist;<br>begin<br> filelist := Tstringlist.Create;<br> getfilelist(ExtractFilePath(Application.ExeName)+'*.exe',faAnyFile,filelist);//寻找程序所在目录下的所有*.dat文件<br>//do something with filelist<br> filelist.free;<br><br>end; <br><br><br>从TSearchRec结构里获得<br>TSearchRec的结构:<br>TSearchRec = record<br>Time: Integer;//Time contains the time stamp of the file.<br>Size: Integer;//Size contains the size of the file in bytes.<br>Attr: Integer;//Attr represents the file attributes of the file.<br>Name: TFileName;//Name contains the DOS filename and extension.<br>ExcludeAttr: Integer;<br>FindHandle: THandle;<br>FindData: TWin32FindData;//FindData contains additional information such as<br>//file creation time, last access time, long and short filenames.<br>end;