config file name

  • Thread starter Thread starter Iwan Petrow
  • Start date Start date
I

Iwan Petrow

Hi,

I use Net Framework 1.1 and windows forms.

How could I take the name of the configuration file at runtime?

Thanks.
 
Hi,

The config used by the framework is named always the same ,
YourProgramName.exe.config , where YourProgramName.exe is the name of the
executable of your app.
you add a config file by selecting "config file" from the add item to the
project
 
Iwan,

What do you mean the name of the config file? The name of the file
should be:

<app name>.exe.config

Hope this helps.
 
So there is no possibility the name would be different from
YourProgramName.exe.config ?

Thanks.
 
Hi,

Iwan Petrow said:
So there is no possibility the name would be different from
YourProgramName.exe.config ?

You may use another name, but then it would be your responsability to
process it.

out of curiosity, what is wrong with the name in the first place? , this is
not the first time people ask this and I'm curious of why
 
Iwan said:
So there is no possibility the name would be different from
YourProgramName.exe.config ?

That is the default. You can get the current file name with the
following code in your application:

AppDomain.CurrentDomain.GetData("APP_CONFIG_FILE").ToString();

If you are creating your own app domain you can specify the name for the
ConfigurationFile. You can not change the config file after the
application domain has finished its first bind. More info can be found at:

http://msdn.microsoft.com/library/e...appdomainsetupclassconfigurationfiletopic.asp
 
If you add an app.config file to the project, the resultant name of the file
after a build will always be the name of the executable plus ".config".

If you actually need something else, you would need to implement your own
configuration file scheme and configuration settings reader.
Peter
 
Back
Top