procedure TForm1.Button1Click(Sender: TObject); begin IF SaveDialog1.Execute THEN RichEdit1.Lines.SaveToFile(SaveDialog1.FileName); end;保存文件至少需要一个流啊,那个流是空的文件就空了
SaveDialog只用来返回文件路径和文件名,不作其他工作 你如果要生成一个空txt文件,可以这样: var Strs: TStringList; begin Strs := TStringList.Create; Strs.SaveToFile('D:\aaa.txt'); Strs.Free; end;
用SaveToFile; OpenDialog和SaveDialog只返回文件名的,不做操作
看下TSaveDialog的描述吧: 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. 最后那句,the selected file name is stored in the FileName property,明白了吧
begin
IF SaveDialog1.Execute THEN
RichEdit1.Lines.SaveToFile(SaveDialog1.FileName);
end;保存文件至少需要一个流啊,那个流是空的文件就空了
你如果要生成一个空txt文件,可以这样:
var
Strs: TStringList;
begin
Strs := TStringList.Create;
Strs.SaveToFile('D:\aaa.txt');
Strs.Free;
end;
OpenDialog和SaveDialog只返回文件名的,不做操作
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.
最后那句,the selected file name is stored in the FileName property,明白了吧