• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 135
  • Last Modified:

Files

How can I get a list of files in directory (not with file list box); Some API or other procedure...........

Cheers
0
desno
Asked:
desno
1 Solution
 
kretzschmarCommented:
hi desno,

from a q from my paq see below

      i can give you a scelleton

      procedure FindFile(PathFileName : string; IncludeSubDirs : Boolean);
      var
        srec : TSearchRec;
        Path, FileName : String;
      begin
       Path := ExtractFilePath(PathFileName);
       FileName := ExtractFileName(PathFileName);

       // CurrentDirectory
       if findfirst(PathFileName,faanyfile,srec) = 0 then
       begin
         repeat
           If Not(srec.attr and fadirectory > 0) then
           begin

                //Do something, get the name (Srec.Name) and fill your list
                //inc a counter (Inc(MyCounter))

           end;
         Until findnext(srec) <> 0;
       end;
       FindClose(SRec);
       { SubDirectories }
       If IncludeSubDirs then
       begin
         if FindFirst(Path+'*.*',FaAnyFile,Srec) = 0 then
         begin
           repeat
             // StartRecursion
             if not(Srec.Name[1] = '.') and (srec.attr and fadirectory > 0)then
               FindFile(Path + Srec.Name + '\' + FileName,IncludeSubDirs)
           Until findnext(srec) <> 0;
         end;
         FindClose(SRec);
       end;
      end;


meikl
0
 
desnoAuthor Commented:
Thanks
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now