Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

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).

Thanks.
Posted
Comments
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.

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.
 
Share this answer
 
Comments
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.
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
 
Share this answer
 
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900