79102157

Date: 2024-10-18 12:55:58
Score: 1
Natty:
Report link

I'm also working with ClickOnce application and let do the update by remote web server, then every time the customer launch the application the file are overwritten.

A suitable solution may be, as answered in short above, to copy the file(s) that should not being updated in a different folder than the one where the main application reside.

This approach can be done with every type of file and the destination folder can be the %appdata% folder so by means of C# you can retrieve this path in the following way:

string appdatapath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

Now, when the application start, you have to check if a dedicated folder existing into the appdatapath above; if not you can create it and copy the interesting file(s) inside; if the folder is already present when the application is updated you can copy back to the main application folder the backup copy of the saved file. In this way you can preserve these file to be rewritten every time by an update process of the application.

While this approach is able to work properly, have also one drawbacks.

When you have to uninstall the application this backup folder, because is outside the application folder, will be not deleted! So be aware about storing this file(s) in a clear way expecially if they are related to private info, keys, passcode or other sensitive stuff.

To overcome such limitation a solution may be to store the file(s) after ciphering them so the content will be "in theory" virtually protected or at least more protected than will be by let them saved into the original way.

Another aspect of this task is if some files need to be updated by the application itself (for example think about a local database that have to work as dynamical data storage about some data acquired from different sensors) and then after some time the application itself needs to be updated.

In this scenario, where the information to be stored is not, let's me say, static, you need to backup it before the application is closed by the user. So you need to do a check when the application is going to be closed hence if some of the files to be kept have changed you need to store them in the backup folder.

So it seems ok, but let see what can be a possible trouble here. If the application is forced to be closed in a not clean way may be this task is not executed and then some data lost if the application update was planned to do at the next application start (this is an option provided by the ClickOnce wizard) because some data was not backup during the last application closing.

Unfortunately, at least I've not found solution inside the standard ClickOnce settings at now, there is no option to exclude some files from being updated after the first deployment and then some alternative way must be implemented to overcome such limitation.

Best regards. Fire

Reasons:
  • Blacklisted phrase (0.5): Best regards
  • Blacklisted phrase (1): regards
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: FIRE FOX