private static object obj = new object();
public void WriteLog(string ex){
lock (obj)
{var filePath = System.AppDomain.CurrentDomain.BaseDirectory + "\\errlogs\\";
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
var fileName = filePath + System.DateTime.Now.ToString("yyyy-MM-dd").ToString() + ".txt";
if (!File.Exists(fileName))
{
var fs = File.Create(fileName);
fs.Close();
}
var sw = new StreamWriter(fileName, true);
sw.WriteLine(ex);
sw.WriteLine(string.Empty);
sw.WriteLine(string.Empty);
sw.Close();
}
}