Finding Machine.Config
OK, this is just a quick little tip. I need to be able to programmatically locate the Machine.Config file. Instead of hard-coding the path where I know it is, I used the new ConfigurationManager class in .NET 2.0 to perform this. Here is the code.
C#
using System.Configuration;
Configuration cnf;
cnf = ConfigurationManager.OpenMachineConfiguration();
MessageBox.Show(cnf.FilePath);
VB.NET
Imports System.Configuration
Dim cnf As Configuration
cnf = ConfigurationManager.OpenMachineConfiguration()
MessageBox.Show(cnf.FilePath)
You will need to add a reference to the System.Configuration.dll to be able to use this, but then you can use File IO or XmlDocument methods to open and affect the Machine.Config.
Hope this helps someone out.
Paul
Past Blog Content
Blog Archive
-
2015
-
2014 (18)
-
2013 (11)
-
2012 (19)
-
2011 (29)
-
2010 (19)
-
2009 (28)
-
2008 (0)
-
2007 (14)
-
2006 (6)