已知目录D:\document\目录下存放有大量.txt文件,现在想取得该目录内所有.txt文件的文件名,例如doc001.txt、doc002.txt、doc003.txt... ...,即取得doc001,doc002,doc003... ...,并一一赋值给一个combobox的item,请问如何编写?
补充一下二楼,全局变量的定义,从百度空间找的
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
found:integer;
dirstr:string;
keyword:string;
rc:TSearchRec;
procedure TForm1.Button1Click(Sender: TObject);
var
s:string;
begin
... ...