S
softwareakash
Hi
I have a class library which takes some values from web config / app
config files when called.
I am initialising these values when my object gets called.
Is there any method to find out if app Settings tag is defined in the
file?
here is my code for initislisation
public class WriteFile
{
// Initialising variables from the config Files
private static readonly string FullFilePath =
GetFilePathConfigSetting("FilePath");
and here is the code for GetFilePathConfigSetting which checks for the
value
public static string GetFilePathConfigSetting(string name)
{
string retVal = ConfigurationSettings.AppSettings[name];
if (retVal == null)
{
return "defaultfile.txt";
}
return retVal;
}
The problem is that when I deliberately remove appSettings tag or the
Filepath tag from the web config.. there is an exception.
can anybody tell where I am making a mistake?
Thanks in advance
Akash
I have a class library which takes some values from web config / app
config files when called.
I am initialising these values when my object gets called.
Is there any method to find out if app Settings tag is defined in the
file?
here is my code for initislisation
public class WriteFile
{
// Initialising variables from the config Files
private static readonly string FullFilePath =
GetFilePathConfigSetting("FilePath");
and here is the code for GetFilePathConfigSetting which checks for the
value
public static string GetFilePathConfigSetting(string name)
{
string retVal = ConfigurationSettings.AppSettings[name];
if (retVal == null)
{
return "defaultfile.txt";
}
return retVal;
}
The problem is that when I deliberately remove appSettings tag or the
Filepath tag from the web config.. there is an exception.
can anybody tell where I am making a mistake?
Thanks in advance
Akash