the following code lists files but not directories
var
rec : tsearchrec;
begin
findfirst('c:\test\*',faanyfile-fadirectory,rec);
showmessage(rec.Name);
if findnext(rec) <> 0 then close else
showmessage (rec.Name);
end;
the following code lists files but not directories
var
rec : tsearchrec;
begin
findfirst('c:\test\*',faanyfile-fadirectory,rec);
showmessage(rec.Name);
if findnext(rec) <> 0 then close else
showmessage (rec.Name);
end;
What about findfirst('c:\test\*', faanyfile, rec); // not faanyfile-fadirectory
If you want all files and directories, just pass in faDirectory to findfirst. It's going to already return you files.
You explicitly excluded directories by stating " - faDirectory" in the flags parameter.
var rec : tsearchrec; begin if FindFirst('c:\*', faAnyFile, rec) = 0 then begin repeat ShowMessage(rec.Name); until FindNext(rec) <> 0; FindClose(rec); end; end;