?
Solved

searching for *.lang

Posted on 2003-11-17
4
Medium Priority
?
266 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
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
Eddie Shipman 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:Eddie Shipman
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

807 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