Click here to Skip to main content
16,018,294 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi everyone,
I have a win application that creates a xml file in runtime in the setup folder path of itself. I have created a setup for my application, but i do not know how can i delete that xml file before the application is uninstalled!!!

I have tried Installer class but it did not worked. I think the problem is that in BeforeUninstall event of it the setup folder path of the application is disposed.

Note : I have used the following code to find the setup folder of my application..

C#
using Microsoft.Win32;

RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Installer\Assemblies");
string regfilepath="";
if (key!=null)       // Make sure there are Assemblies
{
    foreach(string Keyname in key.GetSubKeyNames())
    {
        if (Keyname.IndexOf("YOUR_EXE_FILE.EXE")>0)
        {
    regfilepath=Keyname;
    break;
        }
   }
}
string fullpath="";
for (int a=0;a<regfilepath.Length;a++)
{
  if (regfilepath.IndexOf("|",a,1)>0)
   fullpath+="\\";
 else
  fullpath+=regfilepath.Substring(a,1);
}
Posted

1 solution

I don't think that it is possible what you are trying to do but I imagine a workaround:
can't you write the file to the AppData folder? Then you should be able to delete the file or folder in the AppData folder in the BeforeUninstall or AfterInstallFinished event of your installer.

cheers,
Marco Alessandro Bertschi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900