Torna al Thread

void ScriviSuFile() { if (DateTime.Now.Date > lastLogDate) { // Creo un nuovo file di log con la data corrente. CloseTextFile(); eventWriter = new StreamWriter(Application.StartupPath + @"\log\Events_" + DateTime.Now.ToString("yyyy-MM-dd") + ".log", true); // Svuoto il buffer ogni volta che scrivo sul file. eventWriter.AutoFlush = true; lastLogDate = DateTime.Now.Date; } } void CloseTextFile() { try { eventWriter.Close(); eventWriter.Dispose(); } catch (Exception) { } }
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5