Click here to Skip to main content
12,754,090 members (29,668 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ClickOnce

Can you exclude certain files from an update with ClickOnce?
I don't wanna update for example the local database (so it's empty again).

Posted 12-Jul-11 11:27am
Philippe Mori 12-Jul-11 22:05pm
This might you give the expected result if the user either "Repair" the installation or desinstall and reinstall it again. Better to uses one of the alternate solution based on the fact that the database is create on first use either by copying it or creating it from code.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

One of the best way to handle this would be to copy the file the first time the user run the application.

That solution also works nicely with UAC and multiples users (that don't share the data).

When the application want to use the file (typically in a subdirectory of "My documents"), if the database file does not exists, then you copy the empty file that was installed with your application.
Philippe Mori 12-Jul-11 21:58pm
If the data is not intented to be easily seen by the user, then you can copy it under a subdirectory of the user application data directory.
Philippe Mori 12-Jul-11 22:01pm
An added benefit of having a "template" of your database is that it will works if the user delete its database since it will be then recreated.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

For database, it might even be a better solution to create the file at run-time if it does not yet exist.

There are 2 advantages to this method:

  • The setup file will typically be smaller which is interesting particulary for small application

  • It is somewhat easier to support multiple databases if they are created by code

Philippe Mori 12-Jul-11 22:03pm
Another benefit of using code is that once the application is upgraded, there are chance that the database format has changed some way and that custom code must be run anyway. So if you do it that way from the start, then you have more experience with that when you have to.
kZR 13-Jul-11 13:05pm
I allready perform a check if the file exits and if it doesn't I create a new database with all the tables. The problem is if I update my program it deletes the database thus the file doesn't exits and the program creates an empty database. How do I prefent this from happening?
Philippe Mori 13-Jul-11 16:56pm
Well the first time you would have a problem.... as the current installation was done incorrectly. Upgraded should have been tested before the application was first shipped to an end-user.

If the application is not yet shipped, then modify the application so that it make a copy of the database the first time the application is run.

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 | Mobile
Web02 | 2.8.170217.1 | Last Updated 12 Jul 2011
Copyright © CodeProject, 1999-2017
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