Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# VS2010 setup
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..
 
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 24-Feb-12 22:12pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 424
1 CHill60 410
2 OriginalGriff 355
3 PIEBALDconsult 245
4 BillWoodruff 208


Advertise | Privacy | Mobile
Web04 | 2.8.141015.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100