<configuration>
<configSections>
<sectionGroup name="loggingConfigs">
<section name="LoggingParameters"
type="Framework.Logging.LoggingParameters, Framework.Logging" />
</sectionGroup>
</configSections>
<loggingConfigs>
<LoggingParameters
myconfig="C:mydir\mypath1\mypath2\log4net.config"
/>
</loggingConfigs>
</configuration>
public class LoggingParameters : ConfigurationSection
{
[ConfigurationProperty("myconfig", IsRequired = true)]
private string ConfigFileLoc
{
get { return (string)this["myconfig"]; }
}
public FileInfo MyConfigFile
{
get
{
string s = ConfigFileLoc; <--- getting empty string here..don't know why
return new FileInfo(s);
}
}
}
When I make the following call else where in my application,
FileInfo f = new Framework.Logging.LoggingParameters().MyConfigFile;
the ConfigFileLoc always comes back as blank. I can not figure out why its blank.. why the string is empty.. please help.
I had to remove the SectionGroup (don’t know if that is a requirement for you)
And got the FileInfo with this code (path is not empty anymore)
This post by Scott Mitchell may help you