2017-03-09 154 views
1

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

我想这没有成功......也许有做它不使用代码更简单的方法...

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

谢谢你们! :)

回答

1

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; 
+0

非常完美。谢谢。 –

相关问题