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

Delphi FormClose如何使我的应用程序自动提取此文件夹,delphi,delphi-7,Delphi,Delphi 7,需要我的应用程序时,表单关闭它创建此文件夹自动和每次 此表单将自动打开和关闭并更新文件 +'Userinfo\'+BuddyName+'Archive\'+BuddyName+'); 您可以使用ForceDirectory创建整个文件夹树,然后将文件写入其中: procedure TPMWindow.FormClose(Sender: TObject; var Action: TCloseAction); var FolderPath: string; begin FolderPath

需要我的应用程序时,表单关闭它创建此文件夹自动和每次 此表单将自动打开和关闭并更新文件

+'Userinfo\'+BuddyName+'Archive\'+BuddyName+');
您可以使用ForceDirectory创建整个文件夹树,然后将文件写入其中:

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代替ForceDirectory

是什么阻止了你这么做?我需要知道关于如何让我的应用程序自动提取此路径和更新此表单可用于保存隐私按摩档案保存操作已开始,但必须由我自己创建文件夹我需要应用程序创建此路径+'Userinfo\'+BuddyName+'Archive\'+BuddyName+'自动我需要知道怎么打这个我们不知道你的问题是什么。您已经有了将备注控件的内容保存到文件中的代码。你没有告诉我们问题出在哪里。你没有问任何问题。我想知道“ForceDirectories;”你的问题的答案是吗是的,这很有效。。。这是ForceDirectories更新的、独立于设备的方法,使用TDirectory.CreateDirectory。使用CreateDirectory在给定路径上创建新目录。如果路径中给出的目录还不存在,CreateDirectory会尝试创建它们。@Ron:是的,我知道。我也知道这个问题被特别标记为Delphi 7.:-我添加了一段以包含IOUtils信息,以供将来参考。谢谢
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;