拖一个button,一个ListBox到Form上<br><br>procedure TForm1.ListFilesName(strlist: TstringList; path: string);<br>var<br> searchrec: TSearchRec;<br> Found : Integer;<br>begin<br> if path[length(path)] <> '/' then<br> path := path + '/';<br><br> Found := FindFirst(path+'*.*',fadirectory,searchRec);<br> while Found = 0 do<br> begin<br> if (Searchrec.Attr and fadirectory <> 0) and (Searchrec.Name[1] <> '.') then<br> ListFilesName(strList,Path+SearchRec.Name)<br> else if (searchrec.Name[1] <> '.') then<br> strlist.Add(Searchrec.Name);<br> Found := FindNext(SearchRec);<br> end;<br><br> FindClose(SearchRec);<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> list : TStringList;<br>begin<br> List := TStringlist.Create;<br> ListFilesName(List,'D:/Parser/Parser');//自己的一个目录<br> Listbox1.Items.Assign(List);<br> List.Free;<br>end;<br>