Solved

files&directorys

Posted on 2000-04-26
10
174 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
Comment Utility
check out findfirst/findnext/findclose

BlackDeath.
0
 
LVL 10

Accepted Solution

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

Expert Comment

by:BlackDeath
Comment Utility
hi, ecollin -
1 minute late ;-)
BlackDeath.
0
 
LVL 2

Expert Comment

by:aubs
Comment Utility
//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
Comment Utility
listenning
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Expert Comment

by:BlackDeath
Comment Utility
hi, bryan!

what do you want with this q?

;-)

BlackDeath.
0
 
LVL 3

Expert Comment

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

Expert Comment

by:BlackDeath
Comment Utility
ILPowerSoft - u should grade not disappear...
0
 

Author Comment

by:ILPowerSoft
Comment Utility
Answer accepted
0
 
LVL 1

Expert Comment

by:BlackDeath
Comment Utility
hm.

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

but who cares.
list is growing...

BlackDeath.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

13 Experts available now in Live!

Get 1:1 Help Now