Subversion Repositories Code-Repo

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace SWAT_Office_App
{
    class Debug
    {
        private static string debugLocation = "StatusLog.txt";
        public static void appendText(string text)
        {
            // Appends passed string into Debug.txt
            using (StreamWriter sw = File.AppendText(debugLocation))
            {
                sw.Write("[" + DateTime.Now.ToLongDateString() + " | " + DateTime.Now.ToLongTimeString() + "] -- ");
                sw.Write(text + "\r\n");
                sw.Flush();
            }
        }
        public static void createNewDebugTxt()
        {
            // Deletes old Debug.txt and creates a new one
            if (File.Exists(debugLocation))
            {
                File.Delete(debugLocation);
                File.Create(debugLocation);
            }
        }
        public static void startNewSession()
        {
            using (StreamWriter sw = File.AppendText(debugLocation))
            {
                sw.Write("-- New Session --\r\n");
                sw.Flush();
            }
        }
    }
}