?
Solved

Text Files

Posted on 2003-03-14
3
Medium Priority
?
128 Views
Last Modified: 2010-04-04
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
0
Comment
Question by:HotRod40
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Accepted Solution

by:
ITugay earned 600 total points
ID: 8135196
here is a sample.

drop TEdit (Edit1) on form and enter path there


procedure TForm1.SpeedButton1Click(Sender: TObject);
var
  F: TSearchRec;
begin
  if FindFirst(Edit1.Text + '*.csv', faAnyFile, F) = 0 then
  repeat
    ListBox1.Items.Add(Edit1.Text + F.Name);
  until FindNext(F) <> 0;
  FindClose(F);
end;

-----
Igor
0
 

Author Comment

by:HotRod40
ID: 8137122
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
0
 
LVL 1

Expert Comment

by:Noturno
ID: 8137343
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] (:
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question