| View previous topic :: View next topic |
| Author |
Message |
Rick Guest
|
Posted: Fri Nov 21, 2003 12:21 am Post subject: Show files from a directory |
|
|
Hi,
I have a certain directory filled with files. I want all file from that
directory with extension *.x to be showed in a listbox or something? How to
get these filenames?
Greetings,
Rick
|
|
| Back to top |
|
 |
Mxking Guest
|
Posted: Fri Nov 21, 2003 1:34 am Post subject: Re: Show files from a directory |
|
|
"Rick" <r.nieuwlaat (AT) planet (DOT) nl> wrote:
| Quote: | Hi,
I have a certain directory filled with files. I want all file from that
directory with extension *.x to be showed in a listbox or something? How to
get these filenames?
Greetings,
Rick
|
What you should do is judge the file extension.You can use
function ExtractFileExt(const FileName: string): string;
to get the file's extension.The return of the above function
is the file's extension.
---
Mxking
|
|
| Back to top |
|
 |
Martin Harvey (Demon Acco Guest
|
Posted: Fri Nov 21, 2003 3:18 am Post subject: Re: Show files from a directory |
|
|
On Fri, 21 Nov 2003 01:21:57 +0100, "Rick" <r.nieuwlaat (AT) planet (DOT) nl>
wrote:
| Quote: | Hi,
I have a certain directory filled with files. I want all file from that
directory with extension *.x to be showed in a listbox or something? How to
get these filenames?
|
The Delphi library has FindFirst and FindNext functions, which will
work nicely for this. They encapsulate the Win32 API FindFirstFile and
FindNextFile functions.
MH.
|
|
| Back to top |
|
 |
Dave Keighan Guest
|
Posted: Fri Nov 21, 2003 3:32 am Post subject: Re: Show files from a directory |
|
|
Rick
| Quote: | I have a certain directory filled with files. I want all file from
that directory with extension *.x to be showed in a listbox or
something? How to get these filenames?
|
You can roll your own quick and easy with FindFirst, FindNext ... or go
the custom route - if you plan on any recursion or looking in
sub-directories/folders I'd recommend the custom route.
There are a number of them out there:
http://www.torry.net/search.htm
My preference is:
http://www.delphiarea.com/products/#TFindFile
Slick and easy to use. It has a method that returns each file as it's
found so you can check whatever needs checking and process the
FileMatch as required.
My preference for the list is Virtual TreeView. Takes a bit of mucking
about to get the hang of but very, very cool - even as a listbox.
Alternately, depending on what you may want to do with the files,
there's VirtualShellTools. Find them both at:
http://www.delphi-gems.com/
GL
--
Dave
|
|
| Back to top |
|
 |
Dave Keighan Guest
|
|
| Back to top |
|
 |
Kurt Barthelmess Guest
|
Posted: Fri Nov 21, 2003 1:27 pm Post subject: Re: Show files from a directory |
|
|
"Rick" <r.nieuwlaat (AT) planet (DOT) nl> wrote:
| Quote: | I have a certain directory filled with files. I want all file from that
directory with extension *.x to be showed in a listbox or something? How to
get these filenames?
|
To get them into a listbox:
var
Dir: array [0..MAX_PATH] of Char;
....
StrCopy(Dir, '*.x');
DlgDirList(Handle, Dir, ListBox1.Handle, 0, DDL_ARCHIVE);
Do not pass a literal directory / file mask to DlgDirList. It wants to
modify that input, so pass it a buffer as shown.
You may want to qualify that mask a bit more. With no drive or base
folder, the results are somewhat arbitrary.
If you want the list in "something" what is the "something"?
Good luck.
Kurt
|
|
| Back to top |
|
 |
jacob muntner Guest
|
Posted: Sun Nov 23, 2003 2:41 pm Post subject: Re: Show files from a directory |
|
|
"Rick" <r.nieuwlaat (AT) planet (DOT) nl> כתב בהודעה:3fbd5ab0 (AT) newsgroups (DOT) borland.com...
| Quote: | Hi,
I have a certain directory filled with files. I want all file from that
directory with extension *.x to be showed in a listbox or something? How
to
get these filenames?
|
a TFileListBox looks "something" suitable. just fill in it's
directory and mask properties accordingly.
------
jacob
|
|
| Back to top |
|
 |
Rick Guest
|
Posted: Mon Nov 24, 2003 8:35 pm Post subject: Re: Show files from a directory |
|
|
Thank you all! I got it working now.
Greetings,
Rick
|
|
| Back to top |
|
 |
|