请各路高手赐教~
有以下几个文件夹
文件夹命名规则是:(按日期递增)
列:20051229,20051230,20051231,20060101
在每个文件夹内都有file.txt
但是file.txt的内容各不相同
现在要将这些file.txt文件的内容全部合并到另外一个文本中去,比如:result.txt
要怎样实现呢~小菜鸟望各路大侠侠义相教~,不剩感激~

解决方案 »

  1.   

    使用findfirst和findnext两个函数遍历你的所有文件夹和其下的所有文件,读取符合要求的文件的内容到TStringList类的一个实例中,然后将所读取的内容写入你最后想生成的目标文件。
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);var
      sr: TSearchRec;
      FileAttrs: Integer;
    begin
      StringGrid1.RowCount := 1;
      if CheckBox1.Checked then
        FileAttrs := faReadOnly
      else
        FileAttrs := 0;
      if CheckBox2.Checked then
        FileAttrs := FileAttrs + faHidden;
      if CheckBox3.Checked then
        FileAttrs := FileAttrs + faSysFile;
      if CheckBox4.Checked then
        FileAttrs := FileAttrs + faVolumeID;
      if CheckBox5.Checked then    FileAttrs := FileAttrs + faDirectory;
      if CheckBox6.Checked then
        FileAttrs := FileAttrs + faArchive;
      if CheckBox7.Checked then    FileAttrs := FileAttrs + faAnyFile;  with StringGrid1 do
      begin
        RowCount := 0;    if FindFirst(Edit1.Text, FileAttrs, sr) = 0 then    begin
          repeat
            if (sr.Attr and FileAttrs) = sr.Attr then
            begin
            RowCount := RowCount + 1;
            Cells[1,RowCount-1] := sr.Name;
            Cells[2,RowCount-1] := IntToStr(sr.Size);
            end;
          until FindNext(sr) <> 0;
          FindClose(sr);
        end;
      end;
    end;以上是delphi帮助中关于这些函数使用的例子,你看看。