procedure TForm1.Button1Click(Sender: TObject);
var
f1:textfile;
ch:string;
begin
assignfile(f1,'lb.ml');
append(f1);
if opendialog1.Execute then
ch:=opendialog1.FileName ;
ListBox1.Items.Add(ch);
writeln(f1,ch);
closefile(f1);
end;
那为大侠帮帮忙 为什么每次只能写入一个opendialog1.FileName 第二次以后的都写不进文件如果改成
procedure TForm1.Button1Click(Sender: TObject);
var
f1:textfile;
ch:string;
begin
assignfile(f1,'lb.ml');
if opendialog1.Execute then
ch:=opendialog1.FileName ;
ListBox1.Items.Add(ch);
append(f1);
writeln(f1,ch);
closefile(f1);
就一个opendialog1.FileName 都写不进去了
高手帮帮忙 我刚学一个星期~!!!
先谢谢啦!!
var
f1:textfile;
ch:string;
begin
assignfile(f1,'lb.ml');
append(f1);
if opendialog1.Execute then
ch:=opendialog1.FileName ;
ListBox1.Items.Add(ch);
writeln(f1,ch);
closefile(f1);
end;
那为大侠帮帮忙 为什么每次只能写入一个opendialog1.FileName 第二次以后的都写不进文件如果改成
procedure TForm1.Button1Click(Sender: TObject);
var
f1:textfile;
ch:string;
begin
assignfile(f1,'lb.ml');
if opendialog1.Execute then
ch:=opendialog1.FileName ;
ListBox1.Items.Add(ch);
append(f1);
writeln(f1,ch);
closefile(f1);
就一个opendialog1.FileName 都写不进去了
高手帮帮忙 我刚学一个星期~!!!
先谢谢啦!!
begin
ch:=opendialog1.FileName ;
ListBox1.Items.Add(ch);
writeln(f1,ch);
end;
看来高手都很忙........
我刚发现
如果语句中没有这句opendialog1.Execute 是可以的
procedure TForm1.Button1Click(Sender: TObject);
var
f1:textfile;
ch:string;
begin
assignfile(f1, 'lb.ml ');
ch:=opendialog1.FileName ;
ListBox1.Items.Add(ch);
append(f1);
writeln(f1,‘0000’);
closefile(f1);
点一次按钮 加入一行0000
但是加上opendialog1.Execute就不行了
点击第一次写入0000再点击就什么都写不进去了
那位高手抽点时间帮帮忙嘛~~~~~~~~~~~~~~~!
var
new: TForm2;
begin
if OpenDialog1.Execute then
begin
new:=TForm2.Create(Application);
new.Caption:=OpenDialog1.FileName;
new.RichEdit1.Lines.LoadFromFile(OpenDialog1.FileName); //载入文件
end;
end;
参考一下,,,
var
F:textfile;
ch:string;
begin
assignfile(f,'C:\1.txt');
append(f);
if opendialog1.Execute then
ch:=opendialog1.filename;
ListBox1.Items.Add(ch);
writeln(f,ch);
closefile(f);
end;
我测试过的,能够使用的哈.
和你上面的代码比较,有一下不同点
assignfile(f,'C:\1.txt');//我的代码
assignfile(f1, 'lb.ml '); //你的代码
使用你的代码时:append打开文件出现I0错误,估计要用文件的路径才可以.你换成'lb.ml'的完整路径.就可以了.
append(f); 当打开一个不存在的文件时,出现I0错误,应该先判断一下文件是否存在,不存在先键一个!!!!var
F:textfile;
ch:string;
Path:string;
begin
Path:= 'lb.ml';
assignfile(f, Path);
if not FileExists(Path) then Rewrite(f); //文件不存在,新建一个!
append(f);
if opendialog1.Execute then ch:=opendialog1.filename;
ListBox1.Items.Add(ch);
writeln(f,ch);
closefile(f);
end;