I store all my program's settings in the appdata directory %appdata%/MyProgram. When there is a problem and the user has to reinstall, I want to ask whether to delete the data in that directory. I am using Inno Setup and added a custom page to prompt the user:
if DirExists(ExpandConstant('{userappdata}\MyProgram')) then
begin
appdataPage := CreateInputOptionPage(wpSelectTasks,
'Stored Settings', 'Would you like to remove settings before re-install?',
'Please specify if you would like to remove the current settings before re-installing MyProgram.', True, False);
appdataPage.Add('Remove current settings (Recommended if MyProgram is having problems).');
appdataPage.Add('Keep all my settings and just reinstall.');
//appdataPage.Add();
appdataPage.Values[0] := true;
end;
The installer doesn't put the data there, but the program generates it, thus the uninstaller won't delete it automatically. I also can't count on the uninstaller being run; a lot of users just run the installer again.
How can I handle the selection from this dialog so that if they click 'remove before re-install' I delete the folder %appdata%/MyProgram? I don't want to always delete it, but give them the option.