StreamWriter not creating new file
Posted
by fearofawhackplanet
on Stack Overflow
See other posts from Stack Overflow
or by fearofawhackplanet
Published on 2010-03-22T11:19:56Z
Indexed on
2010/03/22
11:21 UTC
Read the original article
Hit count: 275
I'm trying to create a new log file every hour with the following code running on a server. The first log file of the day is being created and written to fine, but no further log files that day get created. Any ideas what might be going wrong? No exceptions are thrown either.
private void LogMessage(Message msg)
{
using (StreamWriter sw = File.AppendText(_logDirectory + DateTime.Today.ToString("yyyyMMddHH") + ".txt"))
{
sw.WriteLine(msg.ToString());
}
}
© Stack Overflow or respective owner