首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

小弟我的 SaveDialog1 ,小弟我保存了,为什么没有保存成功呢

2012-02-20 
求助:我的 SaveDialog1 ,我保存了,为什么没有保存成功呢?请教:procedureTForm1.Button2Click(Sender:TObje

求助:我的 SaveDialog1 ,我保存了,为什么没有保存成功呢?
请教:
procedure   TForm1.Button2Click(Sender:   TObject);
var
      ss:string;
begin
        ss:= '1234554643 ';
        if       SaveDialog1.Execute   then
                  begin
                            SaveDialog1.FileName:=ss;
                  end;
end;

我明明是保存在桌面   22.txt   ,可是桌面怎么没有这个文件呢?

谢谢!

[解决办法]
看看帮助,通过保存对话框只是让你指定你保存的路径和文件名,接下来的保存工作,你还是要自己写,比如用控件的SavetoFile,

TSaveDialog displays a modal Windows dialog box for selecting file names and saving files. The dialog does not appear at runtime until it is activated by a call to the Execute method. When the user clicks Save, the dialog closes and the selected file name is stored in the FileName property
[解决办法]
haha,你的做法时不正确的。

SaveDialog1 execute后,只是为你要保存的文件选择了一个文件名称,真正的文件保存,写入还需要你自己写。

比如你有一个Tmemo组件mmo1,可以将mmo1的内容存入文件。

procedure TForm1.Button2Click(Sender: TObject);
var
ss:string;
begin
ss:= '1234554643 ';
if SaveDialog1.Execute then
begin
mmo1.lines.savetofile(SaveDialog1.FileName);
end;
end;

热点排行