1

I’m writing an application that should save user specific data into AppData. This application has an installer. Now I’m not sure, what is the best way to provide the folders in AppData.

Should the installer create (and delete) the folders, or should the application itself create (but probably never delete) the folders.

Also, if multiple user on the same computer use the app, the folders probably doesn’t exist, if another user installed the application.

I didn’t found anything that really explained this to me.

Thanks in advance.

Martini Bianco
  • 1,484
  • 1
  • 13
  • 23

2 Answers2

1

I'll answer for Windows Installer, MSI files, and basically you shouldn't need to worry about it in the installer; just install files to their required locations, and the folder will be created automatically and removed at uninstall if it's empty.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
0

In addition to Phil's correct answer:

If the files from the AppData folders used by your application are created only by the application, at run time, there is no need to configure the installer to create the empty folders. Those folders will be created the moment your app writes down the files.

Also, even if your installer is creating the folder, on uninstall it will not remove if in that folder are files created by the application. Windows Installer keeps track (should do it in a correctly configured package) of every file it installs and only removes the ones it installed (by default, it can be configured to force remove a folder and files which it did not install).

Regarding other users of the app. In this scenario, the simplest method is to use your application for creating the initial default files in the AppData folder, at the first launch of the app for each user.

If you need to install files to AppData from your installer then you could try one of the following approaches. These techniques can be applied with any setup authoring tool that can create MSI packages.

Bogdan Mitrache
  • 10,536
  • 19
  • 34
  • It is like this, most of the file that my application creates automatically should be deleted on uninstall. Every persistent file that is created is created with a "Save as" dialog. I thinkt the self healing feature seems to be a solution. But what about uninstall, are the folders deleted on unsinstall, even if they have been created for multiple users? – Martini Bianco Feb 22 '18 at 07:48
  • Old but useful: https://blogs.msdn.microsoft.com/oldnewthing/20070917-00/?p=25103 – Bogdan Mitrache Feb 22 '18 at 08:22
  • Thanks, thats very informative, but sadly doesn’t provide an answer either ;) – Martini Bianco Feb 22 '18 at 12:13
  • A similar topic that might help you in that direction, if you insist on removing the files under all user profiles: https://www.advancedinstaller.com/forums/viewtopic.php?t=20542#p55766 – Bogdan Mitrache Feb 22 '18 at 12:15