Board index » delphi » FindFirst, must find just directories

FindFirst, must find just directories

Hello everybody,

How can I let FindFirst/FindNext only search for directories?

Now I use this;

function TFMMain.GetDirectories(x:integer):String;
var
  s:string;
  Directory:string;
  SearchRec:TSearchRec;
  Found:integer;
begin
  s:='';
  Directory:=ExtractFileDir(Application.ExeName)+'\*. ';
  Found:=findfirst(Directory,faDirectory,SearchRec);
  while Found=0 do
    begin
      if (length(s)+length(SearchRec.Name))<(255-X) then
        begin
          if (SearchRec.Name<>'.') and (SearchRec.Name<>'..') and
(SearchRec.Name<>'Data') then
            s:=s+SearchRec.Name+#13;
          Found:= FindNext(SearchRec);
        end else
        begin {if length >=255-x}
          showmessage('There are to many directories to show');
          Found:=1;
        end;
    end;
  FindClose(SearchRec);
  Result:=s;
end;

What could I use instead of
         Directory:=ExtractFileDir(Application.ExeName)+'\*. ';     ?

Thanks in advance
        G.Oostra

--
--------------------------------------
My homepage: http://www.IAEhv.nl/users/goostra/index.htm
My TornadoPage: http://www.IAEhv.nl/users/goostra/tindex.htm
My brother's homepage: http://www.IAEhv.nl/users/goostra/jhomepage.htm
-------------------------------------

 

Re:FindFirst, must find just directories


Ask for

if (SearchRec.Attr and faDirectory) = faDirectory then ...

And don't forget to set mask to all files

Directory:=ExtractFileDir(Application.ExeName)+'\*.*';

If you've got problems, I could send you the procedure.

Mike ( mm...@gmx.net )

Other Threads