+'Userinfo\'+BuddyName+'Archive\'+BuddyName+');
Procedure TPMWindow.FormClose(Sender: TObject; var Action: TCloseAction);
Begin
button1.click;
memo1.Lines.SaveToFile(ExtractFilePath(Application.ExeName)+'Userinfo\'+BuddyName+'Archive\'+BuddyName+''+BuddyName+'.html');
答案 0 :(得分:2)
您可以使用ForceDirectories
创建整个文件夹树,然后将文件写入其中:
procedure TPMWindow.FormClose(Sender: TObject; var Action: TCloseAction);
var
FolderPath: string;
begin
FolderPath := ExtractFilePath(Application.ExeName) + 'UserInfo\' +
BuddyName + 'Archive\';
if ForceDirectories(FolderPath) then
// Your filename makes no sense to me, but typing it as you wrote it
Memo1.Lines.SaveToFile(FolderPath + BuddyName + BuddyName + '.html');
end;
如果您使用的是包含IOUtils
的更新版本的Delphi,则应使用TPath.Combine
构建FolderPath
,并TDirectory.CreateDirectory
代替而是ForceDirectories
。