views:

27

answers:

2

So I have been writing to

Environment.SpecialFolder.ApplicationData 

this data file, that upon uninstall needs to be deleted. I am using Innos Setup to build my installer. It works great for me. So my data file hangs out in the above path and I do that cause when I used to try to write it to

Application.ExecutablePath

certain boxes I tested it on would throw a nasty error at me trying to write data there. I do research and somehow its not always writable and its how i came up with the Environment.SpecialFolder.ApplicationData

That is why my data file now resides in the SpecialFolder.ApplicationData. Trouble is if the user uninstalls and reinstalls I need that file gone. It might be a short coming of my knowledge of Innos but I cannot figure out how to know where that file will be to tell innos that.

So then I thought I had a clever solution: Innos can run a file when its done uninstalling, so I had my program create this file "uninstallData.bat" that says:

del "the file in my special folder application data path"

and I wrote it out to drumroll

Application.ExecutablePath 

(yes it was a while in development and I had forgot it was't doable.)

So of course I am back to square one, I need to write a file to a path Innos knows about {app} and I need it to be able to delete my data file in the SpecialFolder... i don't care how I do it i just need that file gone.

Are there other Environment. or Application. approches I have missed? Maybe somewhere that is viewable by an uninstaller AND can be written to?

As an aside, I am not sure why my box I develop on can write to the application folder no issue, but it cannot on other boxes... weird.

Any input would be great sorta lost as to how to crack this nut.

A: 

Appliccation.ExecutablePath is not writable per standard defintions - the program files folder should never be manipulated by running applications. Ther area number of special folders for that. Nice that you finally found.... what is properly documented by Microsoft for a LONG time now (minimum 10 years).

I suggest you get a proper installer - WIX comes to my mind. Your problem is totally unrelated to C# - it seems to be totally a "crappy installer" issue. Or provide a PROGRAM (not bat file) to run at uninstall. What exatly is your problem there?

TomTom
I guess its the crappy installer. I could write a separate small file to remove that data file in the Special Folders. Since I am not sure how "standard" the special folders are. Do they change depending upon the operating system. I guess now that i know its called "special folders" I can look it up.
Codejoy
Actually you SHOULD look it up. This is fully documented for a long time. I COULD answer that, but seriously - just hit F1 in Visual Studio while marking it and you get all the documentation.
TomTom
+1  A: 

The environment location is in the user profile. If there are multiple users on the machine, and they all run the application then a copy of the file will be in each profile.

The path also depends on the OS.

Regardless, the current user's app data location is pointed to by %APPDATA% and %LOCALAPPDATA%. These Windows environment variables should be available within Innos.

Andrew Cooper
Thanks I will try this with Innos.
Codejoy