?
Solved

searching for *.lang

Posted on 2003-11-17
4
Medium Priority
?
263 Views
Last Modified: 2012-05-04
I want to look for any files with the extension .lang in a specified directory and and display the filenames without the extensions in a combo-box.

Can anyone plz give me some advice on how to do this ?

Thx in advance
0
Comment
Question by:Professor
[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
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
EddieShipman earned 500 total points
ID: 9764650
Try this:
procedure GetFileList( FileList: TStringList; inDir, Extension : String );
  procedure ProcessSearchRec( aSearchRec : TSearchRec );
  var
    sDate: String;
    w32fd: TWin32FindData;
    fct: TFileTime;
  begin
     if ( aSearchRec.Attr and faDirectory ) <> 0 then
     begin
       if ( aSearchRec.Name <> '.' ) and
          ( aSearchRec.Name <> '..' ) then
       begin
         GetFileList( FileList, Extension, InDir + '\' + aSearchRec.Name );
       end;
    end
    else
    begin
      FileList.Add(aSearchRec.Name);
    end;
  end;
var
  CurDir : String;
  aSearchRec : TSearchRec;
begin
  CurDir := inDir + '\' + Extension;
  if FindFirst( CurDir, faAnyFile, aSearchRec ) = 0 then
  begin
    ProcessSearchRec( aSearchRec );
    while FindNext( aSearchRec ) = 0 do
      ProcessSearchRec( aSearchRec );
  end;
end;

procedure TForm1.FormShow(Sender: TObject);
var
 FL: TStringList;
begin
 FL := TStringList.Create;
 FL.Sorted := True;
 GetFileList( FL, 'c:\eddie', '*.lang' );
 ComboBox1.Items.Assign(FL);
 FL.Free;
end;

0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 9764661
You will have to cut the extesnions of the filename when adding to the FileList, I forgot to do that.
0
 

Author Comment

by:Professor
ID: 9764673
I'll try ... thx
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9765420
To cut the extension off:
var s : string;
s := ExtractFileName(aSearchRec.Name);
s := Copy(s, 1, Length(s) - Length(ExtractFileExt(s));

Geoff M.
0

Featured Post

Industry Leaders: 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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

762 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