Link to home
Start Free TrialLog in
Avatar of HotRod40
HotRod40

asked on

Text Files

Hi,

I need to write a program that gets the names of the files within a certain folder.
A folder will be named and a series of .csv files located within.
I need to be able to get the names of these files and store them in a list so that
I can read through them and do some other stuff.
I have looked at the 'SelectDirectory' function but I dont think this does what I require.

Any help would be great,
Many Thanks
ASKER CERTIFIED SOLUTION
Avatar of Igor UL7AAjr
Igor UL7AAjr
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HotRod40
HotRod40

ASKER

Once these files are in a list box, is there a way that I can loop through the listbox and view the current filename of each iteration.

Ive tried the following but it doesnt work:

var
  i: integer;
  filename: string;
begin
  for i := 0 to lstFiles.SelCount - 1 do
  begin
    filename := lstFiles.Items[lstFiles.ItemIndex];
    ShowMessage(filename);
  end;
end;

Many Thanks
For give me for my poor english (i'm brazilian)

To see all selected items in this listbox:

var
 i: integer;
 filename: string;
begin
 for i := 0 to lstFiles.SelCount - 1 do
 begin
   filename := lstFiles.Selected[i];
   ShowMessage(filename);
 end;
end;

To see ALL items in the listbox, put Items.Count instead of SelCount and Items[i] instead of Selected[i] (: