public void SaveToFile(journal j, string filename, bool overwrite = false) { if (overwrite || File.Exists(filename)) { File.WriteAllText(filename, j.ToString()); } }
static void Main(string[] args) { var j = new journal(); j.AddEntery("Some string 1"); j.AddEntery("Some string 2"); Console.WriteLine(j); var p = new Persistence(); string filename = @"journal.txt"; p.SaveToFile(j, filename, true); Process.Start(filename); Console.WriteLine("Press <enter> to quit:"); Console.Read(); }