Locating application config file

  • Thread starter Thread starter Thomas Koch
  • Start date Start date
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
 
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
 
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
 
Back
Top