Correct way of reading another application's configuration file

  • Thread starter Thread starter Mark Ingram
  • Start date Start date
M

Mark Ingram

Hi, whats the correct way of opening up a different applications
configuration file?

i.e. i want to open someotherapp.exe.config and read the settings
contained in "applicationSettings".

Ive done the following code, but i dont if its the correct method
(doesnt take any form of security into account):

Configuration config = ConfigurationManager.OpenExeConfiguration(path);
ConfigurationSectionGroup configSectionGroup =
config.GetSectionGroup("applicationSettings");


Im using .NET 2.0.

Thanks
 
Hello, Mark!

MI> i.e. i want to open someotherapp.exe.config and read the settings
MI> contained in "applicationSettings".

MI> Ive done the following code, but i dont if its the correct method
MI> (doesnt take any form of security into account):

MI> Configuration config = ConfigurationManager.OpenExeConfiguration(path);
MI> ConfigurationSectionGroup configSectionGroup =
MI> config.GetSectionGroup("applicationSettings");

MI> Im using .NET 2.0.

I'm no sure but ConfigurationManager can open file for exclusive read or write access. It is not good since original application may write smth to the config.

If you want to read some data from config file and that config is Xml, imo it will be more efficient to do it manually.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
Hi,

The config file is in XML format, you can read it as any other XML file.

You have to make sure that it's not in use though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top