views:

210

answers:

1

I have a .NET setup project that installs and uninstalls my application fine but on uninstall it leaves the installation directory behind.

How can I delete this folder during/after the uninstall?

UPDATE: My application creates a cahce file in this directory when it runs which looks like the reason the folder is not removed during the uninstall.

Is there a way to remove this file so that the folder gets removed?

+4  A: 

Normally the folder created during installation will be removed on uninstall.

This does not happen however, if that folder is not empty or another process has an open handle to that folder or a subfolder within. Therefore you should make sure that the folder is not opened somewhere in Explorer or a console window, you application is not running and you didn't place any additional files to that folder.

You can check with Process Explorer for open handles using the Find -> Find Handle or Dll command and entering the name of your installation folder.

You can get extended information and possible error messages by creating a log of your uninstallation:

msiexec /x myProgram.msi /l*vx log.txt
0xA3
That is the problem then. My application creates a cache file the first time it runs. How do I make sure the folder is empty then?
modernzombie
Store your cache file in the application data folder, not under C:\program files.
0xA3