Solved

files&directorys

Posted on 2000-04-26
10
175 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 50 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now