Click here to Skip to main content
13,554,611 members
Rate this:
Please Sign up or sign in to 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..

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)
string fullpath="";
for (int a=0;a<regfilepath.Length;a++)
  if (regfilepath.IndexOf("|",a,1)>0)
Posted 24-Feb-12 22:12pm

1 solution

Rate this: bad
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.

Marco Alessandro Bertschi

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180515.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2018
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