求助:我的 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;