请教:
procedure TForm1.Button2Click(Sender: TObject);
var
   ss:string;
begin
    ss:='1234554643';
    if   SaveDialog1.Execute then
         begin
              SaveDialog1.FileName:=ss;
         end;
end;我明明是保存在桌面 22.txt ,可是桌面怎么没有这个文件呢?谢谢!

解决方案 »

  1.   

    看看帮助,通过保存对话框只是让你指定你保存的路径和文件名,接下来的保存工作,你还是要自己写,比如用控件的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
      

  2.   

    我想把 字符串 '123456' 保存为一个文件,文件名在  SaveDialog1 对话框输入
      

  3.   

    谢谢大哥:procedure TForm1.Button3Click(Sender: TObject);
    var
    ss:TStringList;
    begin
      ss:=TStringList.Create;
      ss.add('1234554643');
        if   SaveDialog1.Execute then
             begin
                 ss.SaveToFile(SaveDialog1.FileName);
             end;
    end;也不行啊~
      

  4.   

    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;