Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > Log and other local file problem
 

Log and other local file problem

Hi,
I have .Net 3.5 SP1 click once application. The application reads/writes files in subfolders beneath the folder the application is executing from. I noticed that Clickonce installation of new client versions places the executable in random folder. This effectively disconnects the new version from previous data.In my case, this is not desireable. What is the standard pattern for maintaining connection to usersfiles for click once client applications?
m6rk  Thursday, July 23, 2009 3:54 PM
Hi m6rk,

I think there are two options for you.
  1. You can mark the files as data files. When new versions of the Applications were installed, all the existing data on the previous version's data directory will be copied to the current version's data directory. See this page for more detail.
  2. Store the files in a common location in the machine. That is store the files on the Application Data Directory. See this page for how to get the path of the Application Data Directory.
If you have any doubts, please feel free to contact me.

Best regards,
Bruce Zhou
Please mark the replies as answers if they help and unmark if they don't.
  • Marked As Answer bym6rk Friday, July 24, 2009 2:10 PM
  •  
Bruce.Zhou  Friday, July 24, 2009 4:28 AM
Hi, m6rk.

We create a folder under LocalApplicationData with the name of our company, and cache files there that we don't want impacted by updates. Note that they will also remain after the user uninstalls the app, which is good and bad. It's good in case they are uninstalling and reinstalling for some reason, but it's bad if you care that you're leaving them behind if they just uninstall.

To get to that folder:

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

So you might do something like this:

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

When you run our application, it checks to see if the Folder with our company name exists, and if it doesn't, we create it and copy the files over there. If the Folder is there, we still check for each file and copy them over if they don't exist. After the first time, everything will exist, and it won't override them unless you specifically code for that.

You will want to add the files to your project, mark them with a build action of "content" and a "copy to output directory" value of "copy always", to make sure they get deployed. They end up in System.Windows.Forms.Application.StartupPath, so you can just copy them from there.

RobinDotNet
Click here to visit my ClickOnce blog!
  • Marked As Answer bym6rk Friday, July 24, 2009 2:10 PM
  •  
RobinDotNet  Friday, July 24, 2009 6:19 AM
Hi m6rk,

I think there are two options for you.
  1. You can mark the files as data files. When new versions of the Applications were installed, all the existing data on the previous version's data directory will be copied to the current version's data directory. See this page for more detail.
  2. Store the files in a common location in the machine. That is store the files on the Application Data Directory. See this page for how to get the path of the Application Data Directory.
If you have any doubts, please feel free to contact me.

Best regards,
Bruce Zhou
Please mark the replies as answers if they help and unmark if they don't.
  • Marked As Answer bym6rk Friday, July 24, 2009 2:10 PM
  •  
Bruce.Zhou  Friday, July 24, 2009 4:28 AM
Hi, m6rk.

We create a folder under LocalApplicationData with the name of our company, and cache files there that we don't want impacted by updates. Note that they will also remain after the user uninstalls the app, which is good and bad. It's good in case they are uninstalling and reinstalling for some reason, but it's bad if you care that you're leaving them behind if they just uninstall.

To get to that folder:

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

So you might do something like this:

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

When you run our application, it checks to see if the Folder with our company name exists, and if it doesn't, we create it and copy the files over there. If the Folder is there, we still check for each file and copy them over if they don't exist. After the first time, everything will exist, and it won't override them unless you specifically code for that.

You will want to add the files to your project, mark them with a build action of "content" and a "copy to output directory" value of "copy always", to make sure they get deployed. They end up in System.Windows.Forms.Application.StartupPath, so you can just copy them from there.

RobinDotNet
Click here to visit my ClickOnce blog!
  • Marked As Answer bym6rk Friday, July 24, 2009 2:10 PM
  •  
RobinDotNet  Friday, July 24, 2009 6:19 AM
Thank you both. This is exactly the information I was looking for.
m6rk  Friday, July 24, 2009 2:11 PM

You can use google to search for other answers

Custom Search

More Threads

• msi custom action with user permissions
• Want to add a registry entry while installation
• Can I eliminate the option to install the app elsewhere?
• number to words
• Custom Actions + check connection string
• Adware?
• Problem with OneClick Installation, error msg on taget machine
• .NET 2.0 prerequisites
• what registry key saves VBA references?
• Deployment Error