Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

files&directorys

Posted on 2000-04-26
10
Medium Priority
?
182 Views
Last Modified: 2010-04-04
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
Comment
Question by:ILPowerSoft
10 Comments
 
LVL 1

Expert Comment

by:BlackDeath
ID: 2750608
check out findfirst/findnext/findclose

BlackDeath.
0
 
LVL 10

Accepted Solution

by:
ECollin earned 200 total points
ID: 2750610
See help about FindFirst, Findnext and Findclose. I think you will find what you need.
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 2750620
hi, ecollin -
1 minute late ;-)
BlackDeath.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 2

Expert Comment

by:aubs
ID: 2750736
//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
 
LVL 3

Expert Comment

by:bryan7
ID: 2753208
listenning
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 2754549
hi, bryan!

what do you want with this q?

;-)

BlackDeath.
0
 
LVL 3

Expert Comment

by:bryan7
ID: 2772908
waiting for something interesting like retrieving the whole desktop tree ;)
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 2776741
ILPowerSoft - u should grade not disappear...
0
 

Author Comment

by:ILPowerSoft
ID: 2885171
Answer accepted
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 2890321
hm.

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

but who cares.
list is growing...

BlackDeath.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question