首页 > 代码库 > delphi里修改下程序
delphi里修改下程序
程序代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Button2: TButton;
Memo1: TMemo;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function searchfile(path:string):TStringList;
var SearchRec:TSearchRec;
found:integer;
list:TStringList;
begin
list:=TStringList.Create;
found:=FindFirst(path+‘\*.*‘,faAnyFile,SearchRec);
while found=0 do
begin
if (SearchRec.Name<>‘.‘) and (SearchRec.Name<>‘..‘) and (SearchRec.Attr<>faDirectory)
then List.Add(SearchRec.Name);
found:=FindNext(SearchRec);
end;
FindClose(SearchRec);
searchfile:=list;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Lines:=searchfile(Edit1.Text);
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Button2: TButton;
Memo1: TMemo;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function searchfile(path:string):TStringList;
var SearchRec:TSearchRec;
found:integer;
list:TStringList;
begin
list:=TStringList.Create;
found:=FindFirst(path+‘\*.*‘,faAnyFile,SearchRec);
while found=0 do
begin
if (SearchRec.Name<>‘.‘) and (SearchRec.Name<>‘..‘) and (SearchRec.Attr<>faDirectory)
then List.Add(SearchRec.Name);
found:=FindNext(SearchRec);
end;
FindClose(SearchRec);
searchfile:=list;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Lines:=searchfile(Edit1.Text);
end;
end.
这个代码实现的功能: 目录录入Edit1.Text中。搜索的文件,存入Memo1
现在要实现: 那如果 Memo1控件中输出出来的是同名文件 (同名文件样本:wenjian.rtf wenjian.txt) 无所谓什么类型 那该改些什么
窗体上要这样的 [local]1[/local]
如果改不了麻烦重新写下代码
delphi里修改下程序
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。