I am trying to use a configuration file in my C # console application. I created the file inside the project by going to New β Application Configuration File and naming it myProjectName.config. My configuration file is as follows:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="SSDirectory" value="D:\Documents and Settings\****\MyDocuments\****" /> </appSettings> </configuration>
The code to access it is as follows:
private FileValidateUtil() { sSDirFilePath = ConfigurationSettings.AppSettings["SSDirectory"]; if (sSDirFilePath == null) Console.WriteLine("config file not reading in."); }
Can someone tell me why this does not work? (I get an error.)
Thanks!!
badPanda
c # file singleton configuration
badpanda
source share