Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-22-2001, 07:46 PM
Mancubus Mancubus is offline
Senior Member
 
Join Date: Jan 2001
Posts: 275
Default How do I list all the Files & folders in a directory (dir command)

I am making an FTP like client/Server program.
How do I list all the Files & Folders in a Directory?
And display them in a listbox.

Cheers,
Dave.
Reply With Quote
  #2  
Old 01-22-2001, 07:59 PM
davidj davidj is offline
Senior Member
 
Join Date: Jan 2001
Posts: 2,900
Default RE: How do I list all the Files & folders in a directory (dir command)

You do not need a TFileListBox; any listbox can receive a list of filenames using the LB_DIR message:


StrCopy(fName, 'c:\*.txt');
SendMessage(ListBox1.Handle, lb_Dir, 18, LongInt(@fName));
Reply With Quote
  #3  
Old 01-22-2001, 11:12 PM
pascal.enz pascal.enz is offline
Member
 
Join Date: Jan 2001
Posts: 73
Default RE: How do I list all the Files & folders in a directory (dir command)

You can list all the files with a FindFirst...FindNext structure. On this way it's possible to find out more about every file.

procedure ReadDir;
var
SR: TSearchRec;
Res: Integer;
begin
Res := FindFirst('*.*', faAnyFile, SR);
while Res = 0 do begin
ListBox1.Items.Add(SR.Name);
// the SR structure can also give you information about filesize and attributes
Res := FindNext(SR);
end;
FindClose(SR);
end;
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 09:45 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.