S
softwareakash
Hi
I have a dll which logs some values in a text file. In this I am
initialising some values as soon as the object gets called like this
public class Logger
{
// Initialising variables from the config Files
private static string FilePath =
ConfigurationSettings.AppSettings["FilePath"];
private static string FileSize =
ConfigurationSettings.AppSettings["MaxFileSizeKB"];
private static string Level =
ConfigurationSettings.AppSettings["LogLevel"];
// Initialising the Filestream and Streamwriter
private static FileStream fs = new FileStream(FilePath,
FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
private static StreamWriter sw = new StreamWriter(fs);
public Logger()
{
}
the problem is that I want to check whether the config file really
exists or the values are correct in the config file and also if the
Filepath is present or not.
If i check all this in the constructor than I cant use static keyword
anymore and I cant use these values in all functions of my dll.
other wise my whole purpose gets lost if Filestream tries to resolve a
Filepath which is not existing, it throws an exception
Can anyone tell me what can be the resolution of this
Regards
Akash
I have a dll which logs some values in a text file. In this I am
initialising some values as soon as the object gets called like this
public class Logger
{
// Initialising variables from the config Files
private static string FilePath =
ConfigurationSettings.AppSettings["FilePath"];
private static string FileSize =
ConfigurationSettings.AppSettings["MaxFileSizeKB"];
private static string Level =
ConfigurationSettings.AppSettings["LogLevel"];
// Initialising the Filestream and Streamwriter
private static FileStream fs = new FileStream(FilePath,
FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
private static StreamWriter sw = new StreamWriter(fs);
public Logger()
{
}
the problem is that I want to check whether the config file really
exists or the values are correct in the config file and also if the
Filepath is present or not.
If i check all this in the constructor than I cant use static keyword
anymore and I cant use these values in all functions of my dll.
other wise my whole purpose gets lost if Filestream tries to resolve a
Filepath which is not existing, it throws an exception
Can anyone tell me what can be the resolution of this
Regards
Akash