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.
Share
This will fill a
TStringsdescendant (eg.,TStringList,TMemo.Lihes, and so forth) with all of the files in a specified folder:Use it like this to populate your
TStringGrid(Gridin 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.