Click here to Skip to main content
Sign Up to vote bad
good
See more: C#ClickOnce
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 12 Jul '11 - 10:27
kZR274

Comments
Philippe Mori - 12 Jul '11 - 22:05
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.

2 solutions

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.
  Permalink  
Comments
Philippe Mori - 12 Jul '11 - 21:58
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:01
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
  Permalink  
Comments
Philippe Mori - 12 Jul '11 - 22:03
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:05
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:56
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
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 498
1 Arun Vasu 275
2 Maciej Los 273
3 Mahesh Bailwal 264
4 Aarti Meswania 175
0 Sergey Alexandrovich Kryukov 9,660
1 OriginalGriff 7,329
2 CPallini 3,968
3 Rohan Leuva 3,339
4 Maciej Los 2,851


Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 12 Jul 2011
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid