I have a window .net application named "XYZ", I have created a custom folder named"ABC" (folder may be anywhere other than application path) while using my application after installation.
When i am uninstalling the application all folders are removed but "ABC" folder remain there.
How can I delete 'ABC' folder which resides other than application path?
You have to use Custom Actions for that:
Code:
public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState);
// Delete folder here.
}
If you don't want to write your own DeleteFolder method add a reference to Microsoft.VisualBasic:
Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory("C:\\MyFiles", Microsoft.VisualBasic.FileIO.DeleteDirectoryOption.DeleteAllContents);
Note: A great example of this is located here. They explain this example in greater detail. Something that was not obvious in this answer at first was the fact you had to add the Installer Class template within the APPLICATION'S project, NOT the Application's SETUP project. Basically the setup project calls the procs Install() and Uninstall() from any application that is added to the Custom Actions in the setup project. The idea is to override those two procs to inject code to do your bidding...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With