dotNetkow
dotNetkow

Reputation: 5313

Fully remove all folders and files on uninstall of Winform app?

Various files and folders remain after uninstalling my Winform application - including content files (pictures, icons, etc.) and a folder for logs that the application creates. For the Content files: in the custom installer project, I have the "Permanent" property set to false. For the logs folder: I assumed this would be deleted with everything else.

Is there a MSI setup property I'm missing or do I need to determine the root path of the Application and remove everything on the overridden Uninstall method?

Upvotes: 4

Views: 3818

Answers (2)

Nikhil Agrawal
Nikhil Agrawal

Reputation: 48568

See installer keeps information about all those files installed by it and when uninstall gets called, this information tells installer which files or folders to remove. After installation if app or user creates any folder or file, those items remain there after even after uninstallation.

But there is a solution. You can write your own custom action under OnAfterUninstall here

protected override void OnAfterUninstall(IDictionary savedState)
{
    base.OnAfterUninstall(savedState);
    // Write your code
}

Upvotes: 0

Ken White
Ken White

Reputation: 125689

No, there's not. The MSI Installer won't uninstall anything it didn't install, which means that user data, log files, etc. are left.

This is by design - can you imagine the liability if the user mistakenly uninstalled your app and wiped out all their financial data or whatever? Or if they'd mistakenly saved other things to your app's data folder, and your uninstaller deleted them?

Upvotes: 3

Related Questions