IN MY CODE
private void WriteToFile(string text)
{
string path = AppDomain.CurrentDomain.BaseDirectory + "\\line Log";
// string path = System.Reflection.Assembly.GetEntryAssembly().Location;
string logFile = "lineSearchAppLogFile" + DateTime.Now.ToString("ddMMyyyy") + ".txt";
string filePath = path+"\\"+logFile;
try
{
if (!Directory.Exists(path))
{
DirectoryInfo di = Directory.CreateDirectory(path);
}
else
{
if (!System.IO.File.Exists(path +"\\log"+DateTime.Now.ToString("ddMMyyyy")+".txt"))
{
// System.IO.File.Create(path + "\\log" + DateTime.Now.ToString("ddMMyyyy") + ".txt");
}
else
{
using (StreamWriter writer = new StreamWriter(path + "\\log" + DateTime.Now.ToString("ddMMyyyy") + ".txt", true))
{
writer.WriteLine(string.Format(text, DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt")));
writer.Close();
}
}
}
}
catch (IOException ioex)
{
Console.WriteLine(ioex.Message);
}
//string logFileName = "lineAppServiceLog.txt";
//using (StreamWriter writer = new StreamWriter(path, true))
//{
// writer.WriteLine(string.Format(text, DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt")));
// writer.Close();
//}
}
in code
AppDomain.CurrentDomain.BaseDirectory = i am getting location D:\\Project\\abc\\abc.line.Platform.lineServices\\bin\\Debug\\
and problem is every time when i rebuild project my folder go delete
so how to make folder outside
Debug folder in window service