Get the configuration folder of a third-party Click-Once application

I am currently messing around with a WPF Click-Once application. This application is a third party application that was not developed by me. I also don't have access to its sources.

It runs on a Windows server periodically and automatically (using a bootstrap launcher written in standard C ++) by following the appropriate link *.appref-ms

that was placed in the start menu path when installing the application. This works great.

Due to intermittent issues with this app, my launcher has to erase all config files before launching it so that I have a well defined launch all the time. These files are placed in one of the application folders. This configuration path for its parameters is read as follows (I found it by searching the AppData tree manually):

C:\Users\<UserName>\AppData\Local\Apps\2.0\Data\WM4WPKCW.P5Z\67QVXD6C.0NT\<app>_f6187a2321850a68_0003.0004_1a67f9f1633c43fc\Data\AppFiles\

      

Note that this configuration path is quite different from the application path (which uses differently named folders):

C:\Users\<User>\AppData\Local\Apps\2.0\5HN2CKMO.MPL\YOL20MYR.O8L\<app>_f6187a2321850a68_0003.0004_f6ab8c93b3a43b7c\

      

Since this config path changes every time the Click-Once app is updated, I need to find it by code (preferably C ++) automatically. Unfortunately, I couldn't figure out how to do this.

How can I get my launcher to find the Click-Once application configuration path based on its file *.appref-ms

?

+3


source to share


1 answer


From Raghavendra Prabhu & rsquo; s blog entry "Client Settings Frequently Asked Questions" :

" If you want to programmatically navigate to the path, you can do so using the configuration management API (you need to add a reference to System.Configuration.dll). For example, here's how you can get the local path of the user.config file:

Configuration config =  
    ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Console.WriteLine("Local user config path: {0}", config.FilePath);

      

C # code (obviously), but shouldn't be that hard to translate to C ++ / CLI.



Raghavendra Prabhu further writes:

" If for some reason you need to save your settings elsewhere, it SettingsProvider

's a good idea to write your own . It's pretty straightforward to implement, and you can find samples in the .NET 2.0 SDK that show you how to do this. Be aware that you may encounter with the same isolation problems discussed above.

Disclaimer: I have not tested this.

+1


source







All Articles