public void LogText(string text,bool logDate) { string path = @"C:\texto.log"; FileStream fs; if (!File.Exists(path)) fs=File.Open(path,FileMode.Create,FileAccess.Write); else fs = File.Open(path, FileMode.Append, FileAccess.Write); using (var outfile =new StreamWriter(fs,Encoding.UTF8)) { string logLine = string.Empty; if (logDate) logLine = String.Format("{0:G} - {1}.", System.DateTime.Now, text); else logLine = text; outfile.WriteLine(logLine); } fs.Close(); }
Blog con recordatorios de soluciones a problemas específicos que me encontré desarrollando software.