Reputation: 1620
I have found that on un-installing myproject setup installer is removing all files but not one conn.cnf
file .I want it to be removed too . so I used custom Actions installer class.but it is not removing that file .
this is my code
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public override void Uninstall(IDictionary savedState)
{try
{
base.Uninstall(savedState);
if (System.IO.File.Exists(Application.StartupPath + "\\Conn.cnf"))
System.IO.File.Delete(Application.StartupPath + "\\Conn.cnf");
}
catch (Exception es) { MessageBox.Show(es.Message); }
}
i have tested if cursor is going in this block or not, by putting a messageBox. which is being execute on un-installation .I have also checked file name ,am i trying to delete file in a wrong way ? Help me. thanks
Upvotes: 1
Views: 509
Reputation: 6849
This is quite difficult to find out the application path. Actually its not an application path its installation directory. When you try to find Application path using Application.StartupPath. You may get C:\System or something like that directory. Because your application is using Windows Installer to uninstall and install the application from the computer and the Windows Installer is installed in System folder. You should try to find Target Directory instead of Application or Executable path.
You can get the Target Directory from the Context Parameter like this.
string targetFolder = Context.Parameters["TARGETDIR"];
Upvotes: 2