procedure TForm1.Button1Click(Sender: TObject);
var
  sr: TSearchRec;
  ret: Integer;
  filename: string;
  path: string;
begin
  path := 'c:\temp\';
  ret := FindFirst(path + '*.*', faAnyfile, sr);
  while ret = 0 do begin
    filename := sr.name;
    ShowMessage(filename);
    ret := FindNext(sr);
  end;
  FindClose(sr);
end;

解决方案 »

  1.   

    path="c:\\demo\\";
    ret=findfirst(path+"*.*",faAnyfile,sr);
    while(ret==0)
    {
      filename = sr.name;
      ret = findnext(sr);
    }
    FindClose(sr);
      

  2.   

    if (SearchRec.Attr and faDirectory)=0 then //表示你要寻找文件
      

  3.   

    FindFirst不会自动遍历目录里面的文件.
    给你一个Delphi procedure:procedure FindFiles(Path: String);
    var sr: TSearchRec;
        ret: Integer;
    begin
      ret := findfirst(Path + '\*.*',faAnyFile,sr);
      while(ret=0) do
      begin
        if Pos('.',sr.Name) = 0 then
          FindFiles(Path + '\' + sr.name);    Form1.Memo1.Lines.Add(sr.name);
        ret := findnext(sr);
      end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      FindFiles('c:\demo');
    end;
      

  4.   

    I'm sorry,FindClose is lost.procedure FindFiles(Path: String);
    var sr: TSearchRec;
        Ret: Integer;
    begin
      Ret := FindFirst(Path + '\*.*',faAnyFile,sr);
      while(Ret=0) do
      begin
        if Pos('.',sr.Name) = 0 then
          FindFiles(Path + '\' + sr.name);    Form1.Memo1.Lines.Add(sr.name);
        Ret := findnext(sr);
      end;
      FindClose(sr);
    end;