ILPowerSoft
asked on
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
exemple
if i give hem the directory c:\windows
he have to give my all the directorys&files in c:\windows
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi, ecollin -
1 minute late ;-)
BlackDeath.
1 minute late ;-)
BlackDeath.
//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.Str ings[i];
MyList.Free;
end;
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
var
MyList: TStringList;
begin
MyList:= TStringList.Create;
ScanDirectory('C:\windows'
for i:= 0 to MyList.Count -1 do
memo1.lines.add(MyList.Str
MyList.Free;
end;
listenning
hi, bryan!
what do you want with this q?
;-)
BlackDeath.
what do you want with this q?
;-)
BlackDeath.
waiting for something interesting like retrieving the whole desktop tree ;)
ILPowerSoft - u should grade not disappear...
ASKER
Answer accepted
hm.
ecollin gave the same comment as me, but 1 minute later.
but who cares.
list is growing...
BlackDeath.
ecollin gave the same comment as me, but 1 minute later.
but who cares.
list is growing...
BlackDeath.
BlackDeath.