Locating application config file

T

Thomas Koch

Hi - I would like to load other files relative to the application config
file.

Do anyone know if this is possible?

If I do Environment.CurrentDirectory it will work if the program is launched
directly from there. Another approach is to combine CurrentDirectory with
the CommandLine string in order to locate the startup assembly, and thus the
directory of the application config file.

It all seems very clumsy to me and I am not even sure that'll work very well
in an ASP.NET application.

I wonder if anyone knows of a better technique.

Cheers
Thomas Koch
 
T

Thomas Koch

Hi - yes I could insert a key value pair which pointed to the location.

However I am building framework software, which is utilizing the application
config file to contain a deployment descriptor. From this deployment
descriptor I need to point to another file, which is usually located
relative to the application config file.

Since I would very much like to offer a "path-independent" format of the
descriptor, so that the user can just move to another path and still have
the refenrece to this other file working.

Cheers
Thomas
 
T

Thomas Koch

Hi Igancio - thanks for the tip on the AppDomain.

It turns out that apparently the AppDomain.CurrentDomain.BaseDirectory
points to the correct directory regardless of running an exe applicatoin or
an ASP.NET

Cheers
Thomas
 

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

Top