
用delphi7.0写一个生成txt文档的程序
2个回答
展开全部
procedure Twrt_Form.N1Click(Sender: TObject);
var
myfile: Textfile;
s,str:string;
begin
richedit1.Text:='';
if opendialog1.Execute then //此处选择你要打开的文件
begin
caption:=opendialog1.FileName;
str:=opendialog1.FileName;
assignfile(myfile,str);
reset(myfile);
try
while not eof(myfile) do
begin
readln(myfile,s); //读文件
richedit1.Lines.Add(s);
end;
finally
closefile(myfile);
end;
end;
end;
var
myfile: Textfile;
s,str:string;
begin
richedit1.Text:='';
if opendialog1.Execute then //此处选择你要打开的文件
begin
caption:=opendialog1.FileName;
str:=opendialog1.FileName;
assignfile(myfile,str);
reset(myfile);
try
while not eof(myfile) do
begin
readln(myfile,s); //读文件
richedit1.Lines.Add(s);
end;
finally
closefile(myfile);
end;
end;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询