Solved

files&directorys

Posted on 2000-04-26
10
176 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Virtuailstring tree compare node issue 14 116
Help on project with Soap 10 53
Magic Software info 18 130
Delphi: making a BW image transparent 10 37
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

786 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