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

How to save a folder when user confirms uninstallation? (Inno Setup)

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

我试过了但没有成功...也许有更简单的方法可以不用代码...

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

谢谢大家! :)

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;