OpenExeConfiguration Path Issue

Posted by Harry on Stack Overflow See other posts from Stack Overflow or by Harry
Published on 2011-11-11T17:07:33Z Indexed on 2011/11/11 17:52 UTC
Read the original article Hit count: 250

I'm trying to load an web.config from a server. Its placed at: \server\folders\web.config

when i try this:

 ConfigurationManager.OpenExeConfiguration(@"\\server\folders\web.config");

it searches for: web.config.config and fails.

 ConfigurationManager.OpenExeConfiguration(@"\\server\folders\web");

it fails, because there is no folder \server\folders\web\

So i tried several things and it seems as its checking wether the file the path is pointing on exists, and afterwards it appliers a .config and gets the config file.

Just for fun i created an web.loaders file, and a web.loaders.config file. with

 ConfigurationManager.OpenExeConfiguration(@"\\server\folders\web.local");

it loads the \server\folders\web.local.config perfectly, but throws Exceptions without the web.local file.

So there a many ways to get this small thing loaded, but isn't there a more nice one than using a temp .web file or something?

Any help i highly appreciated,

yours Harry

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET