You can actually use RemoveFolderEx as any of other WiX extension (XML injection will be required). But... I am also for more elegant solution and for me nothing bits teh elegancy of fully featured C# code :)
You will need just add error handling and that is it. Note that
project.AfterInstall += project_AfterInstall; ... staticvoid project_AfterInstall(SetupEventArgs e) { if (e.IsUninstalling) { var logFiles = Directory.GetFiles(e.InstallDir, "*.log", SearchOption.AllDirectories); foreach (var item in logFiles) IO.File.Delete(item); if(e.Data["UPGRADINGPRODUCTCODE"].IsEmpty()) //only set if triggered by upgrade Registry.CurrentUser.DeleteSubKeyTree("<key path>"); } }
AfterInstall
runs elevated so there will be no problems with the read-write access.