Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > Help required in ClickOnce Deployment Update
 

Help required in ClickOnce Deployment Update

Hi

I have a problem regarding ClickOnce update

The end user store all the data in a XML file called Info.xml.
Now if there is a new version of the
offline tool available and user installs the latest version successfully then
all the files are replaced including the Info.xml. Previously stored data
will be lost.
This is the problem I am facing. When
new versions are available to user then other than updating the Info.xml file
all the rest can be updated. So once the new updates takes place user can still
find the data from Info.xml file.
Deployment strategy used Click Once Application. I have read about Isolated Storage but don't know how to implement it.
Please help me to solve this issue. I am stuck up with this for quite a few days.


sujith_es  Monday, November 17, 2008 8:16 AM

What you should do is store the file somewhere other than IN the application folders.

The first time a user runs our app, we create a folder under LocalApplicationData with our company name, and copy the file over there that we want to start with. Updates are made to the file in the new location.

When updates come through, we check to see if the folder and file are in LocalApplicationData, and if they are, we don't do anything to it.

In C# you can get the folder this way:

string userFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

In VB there is probably a property for it in the MY namespace.

The other advantage to this is that if the user has a probem and has to uninstall and reinstall, his data is still there.

Note that you do NOT want to display that XML file as a Data file, but just mark it as Required in the Application Files dialog. Files deployed as Data are placed in the ApplicationData folder, not in the same folder as System.Windwos.Forms.StartupPath.

RobinS.

GoldMail.com

RobinDotNet  Thursday, November 20, 2008 7:22 AM

Try setting the file to be a "Data" file, I think it will be in the Application Files dialog.

David Guyer MSFT  Monday, November 17, 2008 11:31 PM
Hi David

Thank you for replying. I tried the solution what you mentioned. changing to Data file. Still the problem persists.



sujith_es  Tuesday, November 18, 2008 6:31 AM

What you should do is store the file somewhere other than IN the application folders.

The first time a user runs our app, we create a folder under LocalApplicationData with our company name, and copy the file over there that we want to start with. Updates are made to the file in the new location.

When updates come through, we check to see if the folder and file are in LocalApplicationData, and if they are, we don't do anything to it.

In C# you can get the folder this way:

string userFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

In VB there is probably a property for it in the MY namespace.

The other advantage to this is that if the user has a probem and has to uninstall and reinstall, his data is still there.

Note that you do NOT want to display that XML file as a Data file, but just mark it as Required in the Application Files dialog. Files deployed as Data are placed in the ApplicationData folder, not in the same folder as System.Windwos.Forms.StartupPath.

RobinS.

GoldMail.com

RobinDotNet  Thursday, November 20, 2008 7:22 AM
Hi

Thanks for the reply. I have found another way to copy from data\.pre folder where the old version data file would be stored.

In my case I am able to get the old and new path where the file is stored.
I tried to copy the file from source to destination i.e from .pre to data folder using different methods like File.copy, directory.move etc. I am getting exceptions like file not found (.pre file here in this
case) and directory not found in the case of
directory.move
Can you suggest how to copy the file in these situations from .pre to the current installation folder in clickonce.

sujith_es  Thursday, November 20, 2008 11:29 AM
Sujith_ES wrote:
Hi

Thanks for the reply. I have found another way to copy from data\.pre folder where the old version data file would be stored.

In my case I am able to get the old and new path where the file is stored.
I tried to copy the file from source to destination i.e from .pre to data folder using different methods like File.copy, directory.move etc. I am getting exceptions like file not found (.pre file here in this
case) and directory not found in the case of
directory.move
Can you suggest how to copy the file in these situations from .pre to the current installation folder in clickonce.


You need to check if these files or foldersare existed first. Then use the method to copy or move files to your destination folder.

Myexp  Friday, November 21, 2008 9:17 AM

The data files are only copied into the .\pre folder if they are different than they were in the last version. Otherwise you can get at them via the ApplicationDeployment.DataDirectory property.

What happens is files designated as "Data(Include)" in the Application Files dialog are copied to the location defined as ApplicationDeployment.DataDirectory.

When a new version is published, the deployment checks to see if the included data file has changed. If it has, it copies the prior version to the .\pre folder. If it hasn't, it does not.

When deploying a database, this gives you the opportunity to check and see if there is a previous version, and copy all of the data forward if there is.

So your best bet is still to just include the xml file and not mark it as data, and just copy it from System.Windows.Forms.StartupPath to the destination folder when you need to. This is less complicated.

RobinS.

GoldMail.com

RobinDotNet  Saturday, November 22, 2008 8:42 PM
Hi Robin,

where to paste the follow C# code in VSde?

"

In C# you can get the folder this way:

string userFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);"

Chiefmega  Friday, August 14, 2009 3:23 AM
if answer is not a proper answer.. how?
Chiefmega  Tuesday, August 25, 2009 8:10 AM


Put it in the startup of your application. If you only want it copied the first time, check to see if it exists and only copy it if it doesn't. Something like this:

string userfilepath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, "mycompanyname");
if (!DirectoryExists(userfilepath))
Directory.Create(userfilepath);
if (!File.Exists(Path.Combine(userfilepath, "myfilename.txt")))
File.Copy(Path.Combine(System.Windows.Forms.Application.StartupPath, "myfilename.txt"), userfilepath);

RobinDotNet


Click here to visit my ClickOnce blog!
RobinDotNet  Monday, August 31, 2009 3:35 AM

You can use google to search for other answers

Custom Search

More Threads

• Why Does Click Once Fail only some PCs? HELP!!!
• Applications are not available offline - ClickOnce deployment.
• Registry string value is deleted during un-installation.
• Could Not Register Type Library error
• VS2003 upgraded deployment project not picking up changes to projectinstaller code
• Deploying and using a shared library as merge module
• Windows Installer sometimes silently fails to install data files under [LocalAppDataFolder]
• command line vs gui
• MsInstall Product error 1638 when re-install
• Erro.Number and Err.Description object and Space object