I am using C# and .NET 4.0 framework to develop a WPF application. I need to perform a task like this: Before installing my WPF application on the desktop, I need to remove some folder in that installing desktop. I tried the below one in:
File installer.cs
this.BeforeInstall +=new InstallEventHandler(Installer_BeforeInstall);
void Installer_BeforeInstall(object sender, InstallEventArgs e)
{
// Code
}
Whatever code I used in the above methods to remove the folder/directory are executed after my WPF application installed, means in half of the installation. I need to remove the folder before the WPF application saves the installation folder on my desktop. How do I do this in C# using .NET 4.0?
Update: installer.cs
namespace namespace name
{
[RunInstaller(true)]
public partial class Installer : System.Configuration.Install.Installer
{
public Installer()
{
InitializeComponent();
this.AfterInstall += new InstallEventHandler(ServiceInstaller_AfterInstall);
this.BeforeUninstall += new InstallEventHandler(ServiceInstaller_BeforeUninstall);
}
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
}
void ServiceInstaller_AfterInstall(object sender, InstallEventArgs e)
{
//code
}
void ServiceInstaller_BeforeUninstall(object sender, InstallEventArgs e)
{
// Code
}
}
}