//这里使用C# winform
public void Log(string ex)
{try
{
string filename = DateTime.Now.ToString("yyyyMMdd") + ".txt";
FileInfo file = new FileInfo( System.AppDomain.CurrentDomain.BaseDirectory+ filename); //如果是web程序,这个的变成Http什么的
StreamWriter sw = null;
if (!file.Exists)
{
sw = file.CreateText();
sw.WriteLine(ex.ToString());
}
else
{
sw = file.AppendText();
sw.WriteLine(ex.ToString());
}
sw.Close();
sw.Flush();
sw.Dispose();
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}