高手请帮忙 :简单的扩展名问题(50分)

  • 主题发起人 主题发起人 kenneth
  • 开始时间 开始时间
K

kenneth

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.N9Click(Sender: TObject);
Var F:TextFile;
M:Integer;
begin
If SaveDialog1.Execute then
If SaveDialog1.FileName<>'' then
begin
AssignFile(F,SaveDialog1.FileName);
Rewrite(F);
SaveDialog1.DefaultExt :='.txt';
for M :=0 to listbox1.Items.Count-1 do
begin
Writeln(F,listbox1.Items.strings[m]);
end;
CloseFile(F)
end
end;
为什么我这样保存的文件的扩展名不会为.txt的,错在哪里?请指点
 
设置SAVEDIALOGE中的defalutext为TXT
 
SaveDialog1.DefaultExt :='.txt';
AssignFile(F,SaveDialog1.FileName);
Rewrite(F);
SaveDialog1.DefaultExt :='.txt';
这句移到前面
 
procedure TForm1.N9Click(Sender: TObject);
Var F:TextFile;
M:Integer;
begin
If SaveDialog1.Execute then
If SaveDialog1.FileName<>'' then
begin
SaveDialog1.DefaultExt :='.txt';
AssignFile(F,SaveDialog1.FileName);
Rewrite(F);
for M :=0 to listbox1.Items.Count-1 do
begin
Writeln(F,listbox1.Items.strings[m]);
end;
CloseFile(F)
end
end;
 
procedure TForm1.N9Click(Sender: TObject);
Var F:TextFile;
M:Integer;
begin
SaveDialog1.DefaultExt :='txt';
//ADDED
If SaveDialog1.Execute then
If SaveDialog1.FileName<>'' then
begin
AssignFile(F,SaveDialog1.FileName);
Rewrite(F);
//SaveDialog1.DefaultExt :='.txt';

for M :=0 to listbox1.Items.Count-1 do
begin
Writeln(F,listbox1.Items.strings[m]);
end;
CloseFile(F)
end
end;
 
OK,谢谢啦
 
后退
顶部