-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogfile.cs
More file actions
49 lines (45 loc) · 1.23 KB
/
logfile.cs
File metadata and controls
49 lines (45 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.IO;
using System.Windows.Forms;
namespace generalgff
{
public static class logfile
{
#if DEBUG
const string Logfile = "logfile.txt";
#endif
/// <summary>
/// Creates a logfile (overwrites the previous logfile if it exists).
/// </summary>
public static void CreateLog()
{
#if DEBUG
string pfe = Path.Combine(Application.StartupPath, Logfile);
// string pfe = Path.Combine(Application.StartupPath, "logfile" + System.Diagnostics.Process.GetCurrentProcess().Id + ".txt");
using (var sw = new StreamWriter(File.Open(pfe,
FileMode.Create,
FileAccess.Write,
FileShare.None)))
{}
#endif
}
/// <summary>
/// Writes a line to the logfile.
/// </summary>
/// <param name="line">the line to write</param>
public static void Log(string line)
{
#if DEBUG
string pfe = Path.Combine(Application.StartupPath, Logfile);
// string pfe = Path.Combine(Application.StartupPath, "logfile" + System.Diagnostics.Process.GetCurrentProcess().Id + ".txt");
using (var sw = new StreamWriter(File.Open(pfe,
FileMode.Append,
FileAccess.Write,
FileShare.None)))
{
sw.WriteLine(line);
}
#endif
}
}
}