tags:

views:

281

answers:

1

Hi,

I have he following situation which I really need to resolve as soon as possible and your advise would be very appreciated.

I have a clickonce application which after it is installed on the client machine the first time it creates folders X, Y and Z. Now as the user starts to use the application he creates various files in this folders. Later on a new version of the application is available and he updates the application from version 1.0.0.0 to 1.0.0.1. The end result is that the folders X,Y and Z are created again (and are empty) and the user does not see the previous created by him files. How do we propagate the files from the versions and guarantee that the first time the app is installed the folders X,Y and Z will be created automatically?

I appreciate your help.

Thanks.

+2  A: 

Am I correct in assuming this is specifically a problem with folders and files created within the application's DataDirectory?

I can think of two solutions:

  1. After an update, the contents of the DataDirectory are copied into the new version's DataDirectory and placed in a subfolder called .pre. You can programmatically check to see if an update has just been downloaded using ApplicationDeployment.CurrentDeployment.IsFirstRun and then write your own migration code to move the appropriate folders from .pre into the parent directory.

  2. A different answer, and the one we've used, is to bypass the ClickOnce DataDirectory completely and set your own folder up in the user's Application Data directory (remembering to use the .NET alias for that folder). A downside to this approach is that the folders will not be automatically uninstalled if you uninstall the application from Add/Remove programs. Several upsides are:

    • The folders persist through the uninstall/reinstall that's sometimes necessary when dealing with a corrupted ClickOnce cache (less frequent than a few years ago, but still an occasional issue).

    • The folders follow a user that is using roaming profiles (our experience has been that in a roaming profile situation, the ClickOnce directories are not configured to roam).

    • The folders are easier to find if having to do over-the-phone or email IT support due to problems in those data files. Even IT folks often times have trouble finding the ClickOnce data directory (which has a parent directory that is hidden), but most folks can find your company's directory in Application Data easily. YMMV if you need to obfuscate the location of those files for security reasons.

Richard Dunlap