I am working with Delphi 7 and I would like to list all the files in a given directory in a string grid (one file per row and all in 1 column). I have searched for about an hour now and cannot find any examples on how to do this so any help you can provide would be appreciated.
Delphi – list all files from a directory in a string grid with delphi
delphifilelisttstringgrid
Related Solutions
if you use delphi 2010 then you can use tdirectory.getfiles first add ioutils.pas to uses clause then write the following line of code in the event handler(in addition to code you already have in that event handler)
uses IOUtils;
var
path : string;
begin
for Path in TDirectory.GetFiles(OpenPictureDialog1.filename) do
Listbox1.Items.Add(Path);{assuming OpenPictureDialog1 is the name you gave to your OpenPictureDialog control}
end;
I have posted the complete set of demos for SOAP on CodeCentral as item 28789.
These contain every single one of the Delphi 2007 era SOAP demos from the WebServices
folder, now updated for Delphi XE and XE2, including converting the old WAD servers into new INDY VCL servers. You'd think that was impressive, except it's not. It's really easy. Just use the wizard to create a new project, and then add the web service interface and implementation units, and any other units that belong in the old demo, to the project. Once they're added to the project, they just work. Basic demo SOAP Servers are really easy to build in Delphi, once you have a working demo, you'll find it's pretty easy to modify and extend it.
The demo that best answers the question I asked above is in the SOAPDataModule
sub-folder.
The basic problems with the demo from the 2007 era are two:
The WAD (web app debugger) is gone. you have to make a new server using the Indy server, for optimal demo purposes, saving you from using WAD (which is gone) or setting up ISAPI environment, under IIS, which is hardly ideal for demo purposes. The new demo project I made is called SoapDMServerINDY, and it consists of a data module (datamod_u.pas), a VCL form User Interface unit (
IndyServerVCLFormUnit.pas
) and an Indy Server web module, calledIndyServerWebModule.pas
.The Delphi 2007 demo broke thanks to the new practice of having a Debug/Win32 subfolder that the demo executable is now in, you need to go up further. I fixed the demo server so that it warns you with an error message if the data files cannot be located, saving you from the mysterious "XML parsing error". I also added some error checking in a few of the demos so that it tells you that you need to install interbase for this demo to work, since some of the demos require Interbase installed and running, and one requires an alias called IBLOCAL to exist, and preferably a table called
EMPLOYEE
to exist.
The elements of this demo are a server (SoapDMServerINDY, based on the code from SOAPDMServerWAD), and the client SOAPDMClient which connects to the demo and has two pages, one page will show basic data access via a DBGrid + dataset remoting, and the second page shows how to invoke a custom SOAP method.
To use the demo: You have to start the server, click the start button, then start the client and click Connect.
Best Answer
This will fill a
TStrings
descendant (eg.,TStringList
,TMemo.Lihes
, and so forth) with all of the files in a specified folder:Use it like this to populate your
TStringGrid
(Grid
in the code below - I added code to auto-size the column based on the length of the longest filename):Note that this code requires the path to include the trailing backslash after the folder name; you can modify it easily to automatically add it if needed, or to accept both a folder name and a file mask to include only certain files.