How can I get the name of the application config file?

To determine the path and name of the application configuration file at run time, you can use the ConfigurationFile property of the current application domain object (this works for both Windows Forms and ASP .NET applications).

For example, in C#:

// Get the current application domain object
System.AppDomain domain = System.Threading.Thread.GetDomain();

// Get the path and name of the application configuration file
string config = domain.SetupInformation.ConfigurationFile;

And in VB .NET:

' Get the current application domain object
Dim domain As System.AppDomain = System.Threading.Thread.GetDomain()

' Get the path and name of the application configuration file
Dim config As String = domain.SetupInformation.ConfigurationFile


Interestingly, this returns the name of the application configuration file, even if the file doesn't exist! Basically, it's telling you what the name of the application configuration file should be.


© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 07/05/04
Comment or report problem with topic