示例#1
0
 public void SaveToFile(JournalGood journal, string filename, bool overwrite = false)
 {
     if (overwrite || !File.Exists(filename))
     {
         File.WriteAllText(filename, journal.ToString());
     }
 }
示例#2
0
        static void Main2(string[] args)
        {
            var j = new JournalGood();

            j.AddEntry("I cried today.");
            j.AddEntry("I ate a bug.");
            Console.WriteLine(j);

            var p        = new Persistence();
            var filename = @"c:\temp\journal.txt";

            p.SaveToFile(j, filename);
            Process.Start(filename);
        }