怎么将一个文件夹的所有文本文件名读取,然后在分别读取每个文件的内容

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    var ss:TSearchRec;
    filepath:string;
    begin
        filepath:='c:\';
        listbox1.Items.Clear;
        if FindFirst(filepath+'\*.txt',faanyfile,ss)=0 then
        begin
        if not ((ss.attr and fadirectory)=fadirectory) then
        listbox1.items.Add(ss.name);
        while findnext(ss)=0 do
        begin
        if not((ss.attr and fadirectory)=fadirectory) then
        listbox1.items.add(ss.Name);
        end;
        findclose(ss);
        end;
    end;