Subversion Repositories Code-Repo

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
65 Kevin 1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.IO;
6
using System.Windows.Forms;
7
 
8
namespace SWAT_USB_App
9
{
10
    class Debug
11
    {
12
        private static string debugLocation = Initialization.pathToSWATDrive + "Debug.txt";
13
        public static void appendText(string text)
14
        {
15
            // Appends passed string into Debug.txt
16
            try
17
            {
18
                using (StreamWriter sw = File.AppendText(debugLocation))
19
                {
20
                    sw.Write("[" + DateTime.Now.ToLongDateString() + " ; " + DateTime.Now.ToLongTimeString() + "] -- ");
21
                    sw.Write(text + "\r\n");
22
                    sw.Flush();
23
                }
24
            }
25
            catch (Exception e)
26
            {
27
                MessageBox.Show(e.ToString());
28
            }
29
        }
30
        public static void createNewDebugTxt()
31
        {
32
            // Deletes old Debug.txt and creates a new one
33
            if (File.Exists(debugLocation))
34
            {
35
                File.Delete(debugLocation);
36
                File.Create(debugLocation);
37
            }
38
        }
39
        public static void startNewSession()
40
        {
41
            try
42
            {
43
                using (StreamWriter sw = File.AppendText(debugLocation))
44
                {
45
                    sw.Write("-- New Debug Session --\r\n");
46
                    sw.Flush();
47
                }
48
            }
49
            catch (Exception e)
50
            {
51
                MessageBox.Show(e.ToString());
52
            }
53
        }
54
 
55
    }
56
}