Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > Preserving folders between ClickOnce application updates.
 

Preserving folders between ClickOnce application updates.

Hi,
�br/>
I have he following situation which I really need to resolve as soon as possible and your advise would be very appreciated.
�br/>
I have a clickonce application which after it is installed on the client machine the first time it creates folders X, Y and Z. Now as the user starts to use the application he creates various files in this folders. Later on a new version of the application is available and he updates the application from version 1.0.0.0 to 1.0.0.1. The end result is that the folders X,Y and Z are created again (and are empty) and the user does not see the previous created by him files. How do we propagate the files from the versions and guarantee that the first time the app is installed the folders X,Y and Z will be created automatically?�br/>
PS. Folders X,Y and Z curently are marked as "Content" publish status.


I appreciate your help.
�br/>
Thanks.

Akrion  Thursday, August 13, 2009 1:18 PM

What you need to do is put the folders under LocalApplicationData instead of relying on them being in the same location as the application deployment files. So when the application runs, you can check and see if the folders are there, and if they are, do nothing. If they aren't, create them and put the data there that you want there.

Generally, you would create a folder with your company name under LocalApplicationData and maintain it yourslef.

You can access the local application data folder this way:

string userFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string myAppCache = Path.Combine(userFilePath, "mycompanyname");

string sourceFolder = Path.Combine(System.Windows.Forms.Application.StartupPath, "foldername");

If (!Folder.Exists(Path.Combine(myAppCache, "folder1")))
{
Directory.Create(Path.Combine(myAppCache, "folder1"));
//you might copy files here, or create directories, or whatever
}

and so on.

RobinDotNet

Click here to visit my ClickOnce blog!
RobinDotNet  Monday, August 17, 2009 8:44 AM

What you need to do is put the folders under LocalApplicationData instead of relying on them being in the same location as the application deployment files. So when the application runs, you can check and see if the folders are there, and if they are, do nothing. If they aren't, create them and put the data there that you want there.

Generally, you would create a folder with your company name under LocalApplicationData and maintain it yourslef.

You can access the local application data folder this way:

string userFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string myAppCache = Path.Combine(userFilePath, "mycompanyname");

string sourceFolder = Path.Combine(System.Windows.Forms.Application.StartupPath, "foldername");

If (!Folder.Exists(Path.Combine(myAppCache, "folder1")))
{
Directory.Create(Path.Combine(myAppCache, "folder1"));
//you might copy files here, or create directories, or whatever
}

and so on.

RobinDotNet

Click here to visit my ClickOnce blog!
RobinDotNet  Monday, August 17, 2009 8:44 AM

You can use google to search for other answers

Custom Search

More Threads

• How to prevent the deletion of the old folder with AppUpdater
• Where is a ClickOnce app installed?
• Multi Disk Setup in VS 2005
• Override Eventlog Creation In Service Install
• clickonce prerequisites always deployed
• VS 2008 SP1, Click Once, Prerequisites, Client Profile option + 3.5 SP 1 option
• Multiple EXE files - Changing <EntryPoint> in Manifest
• Deploying .Net 1.1, 2, SQL Server Express in one setup project
• ClickOnce Won't Update a Application if it's passed command line arguments. Bug?
• ClickOnce Deployment Error