FormClose如何使我的应用程序提取此文件夹自动

时间:2015-02-05 13:19:30

标签: delphi delphi-7

表单关闭时创建此文件夹自动,每次都需要我的应用程序 这个表单打开和关闭它会更新文件Auto。

+'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');

1 个答案:

答案 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

相关问题