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

files&directorys

How can I view all the items that I have in sorter directory?
exemple
if i give hem the directory c:\windows
he have to give my all the directorys&files in c:\windows
0
ILPowerSoft
Asked:
ILPowerSoft
1 Solution
 
BlackDeathCommented:
check out findfirst/findnext/findclose

BlackDeath.
0
 
ECollinCommented:
See help about FindFirst, Findnext and Findclose. I think you will find what you need.
0
 
BlackDeathCommented:
hi, ecollin -
1 minute late ;-)
BlackDeath.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
aubsCommented:
//scan directory tree and return a list of all files and directories
procedure ScanDirectory(Dir: String; var FileList: TStringList);

          procedure SearchTree;
          var
            sRec    : TSearchRec;
            RetCode : Integer;
            Dir     : String;
          begin
            GetDir(0, Dir);
            if Dir[length(Dir)] <> '\' then Dir := Dir + '\'; //add trailing slash
            RetCode := FindFirst('*.*', faAnyFile, sRec);
            try
              while RetCode = 0 do
              begin
                if not(SRec.Attr AND faDirectory = faDirectory) then {ignore directories}
                  FileList.Add(Dir + SRec.Name);

                RetCode := FindNext(SRec);
              end;
            finally
              FindClose(SRec);
            end;

            //Go for the subdirectories
            RetCode := FindFirst('*.*', faDirectory, sRec);
            try
              while RetCode = 0 do
              begin
                if (SRec.Attr AND faDirectory = faDirectory) and (SRec.Name[1] <> '.') then {directories}
                begin
                  ChDir(SRec.Name);
                  SearchTree; //time for recursion
                  ChDir('..'); //back up a level
                end;
                RetCode := FindNext(SRec);
              end;
            finally
              FindClose(SRec);
            end;
          end;

begin
  //Clear existing Files...
  FileList.Clear;

  //Change to start directory
  Chdir(Dir);

  //Start file list scan
  SearchTree;
end;



procedure TForm1.Button1Click(Sender: TObject);
var
  MyList: TStringList;
begin
  MyList:= TStringList.Create;
  ScanDirectory('C:\windows',MyList);
  for i:= 0 to MyList.Count -1 do
    memo1.lines.add(MyList.Strings[i];
  MyList.Free;

end;



0
 
bryan7Commented:
listenning
0
 
BlackDeathCommented:
hi, bryan!

what do you want with this q?

;-)

BlackDeath.
0
 
bryan7Commented:
waiting for something interesting like retrieving the whole desktop tree ;)
0
 
BlackDeathCommented:
ILPowerSoft - u should grade not disappear...
0
 
ILPowerSoftAuthor Commented:
Answer accepted
0
 
BlackDeathCommented:
hm.

ecollin gave the same comment as me, but 1 minute later.

but who cares.
list is growing...

BlackDeath.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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