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

How to backup a specific folder on the user's desktop when the user confirms the removal of the application?

I tried this without success ... Maybe there is an easier way to do this without using code ...

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

Thanks guys!:)

+1
source share
1 answer

Running a backup on CurUninstallStepChanged(usUninstall) is the best solution.

You have a problem:

Using the DirectoryCopy custom function (from the question above) you can:

 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; 
+1
source

Source: https://habr.com/ru/post/1234701/


All Articles