用户确认卸载时如何保存文件夹? (创新设置)

问题描述 投票:0回答:1

当用户确认卸载应用程序时,如何将特定文件夹的备份副本保存到用户桌面?

我尝试过但没有成功...也许有一种更简单的方法可以在不使用代码的情况下做到这一点...

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
  if CurUninstallStep = usUninstall then
  begin
    CopyFile('{app}\Profile\*', '{userdesktop}\Backup\Profile\', False);
  end;
end;

谢谢你们! :)

backup inno-setup uninstallation pascalscript
1个回答
4
投票

CurUninstallStepChanged(usUninstall)
上触发备份是最好的解决方案。

您遇到的问题是:

使用

DirectoryCopy
用户功能(来自上面引用的问题),您可以执行以下操作:

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
  SourcePath: string;
  DestPath: string;
begin
  if CurUninstallStep = usUninstall then
  begin
    SourcePath := ExpandConstant('{app}\Profile');
    DestPath := ExpandConstant('{userdesktop}\Backup\Profile');
    Log(Format('Backing up %s to %s before uninstallation', [
      SourcePath, DestPath]));
    if not ForceDirectories(DestPath) then
    begin
      Log(Format('Failed to create %s', [DestPath]));
    end
      else
    begin
      DirectoryCopy(SourcePath, DestPath);
    end;
  end;
end;
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.