Is there a way to find the name (and path) of the current application's config file from inside a class library?
E.g. in a web app this would be web.config
, in a windows app or service this would be myapp.exe.config
.
Configuration files are normally saved in the Settings folder inside the My Documents\Source Insight folder.
The master server configuration file is /etc/named. conf. The configuration file contains a list of domain names and the file names containing host information. See The named.
The Machine. config file is located in the %SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG\ directory.
Try this:
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
If that doesn't work, add references to System.Web and System.Configuration, then try this:
if(HttpRuntime.AppDomainAppVirtualPath == null)
return ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).FilePath;
else
return VirtualPathUtility.ToAbsolute("~/Web.config");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With