ClickOnce and Application Data Directories

The application that I am porting to VS2005 has off-line capabilities. In VS2003, after looking at a lot of options, I chose to store the data in the App folder of the All Users area in c:\directory and settings. One reason for this is that it is possible that a laptop will be passed off from one user to another and they need a common area that they can access. The other reason is that occasionally we might need to get at that data manually if there is a problem. This is the main reason why isolated storage was not an option.

I was able to get to this folder with

System.IO.Directory.GetParent(System.Windows.Forms.Application.CommonAppDataPath)

Not so in ClickOnce.

ClickOnce installs apps into a user’s local storage – (Directory and settings/user/local settings/apps). This means that on shared computers, there may be multiple copies of the application. I don’t like that and will see if there is a way around it since I am manually generating manifest files anyway, but I can live with it.

It also means that the above method returns the data directory defined by ClickOnce, which is inside of this install (rather, in the same parent folder). Not just that, but there will be a different one for each update of the application. This is bad bad bad (for my application).

You can read more about this here in the docs, online.

Even though the LocalSettings  folder is a safe folder as far as CAS is concerned, I don’t like the idea of hardcoding that file path (or making it a resource). But at this point, I think it’s going to be the solution. Bah!

Don’t Forget: www.acehaid.org

  Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!  

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.