-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReadSettings.cs
67 lines (61 loc) · 1.96 KB
/
ReadSettings.cs
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectCreator
{
public class ReadSettings
{
private string DefaultProjectDir;
private int DefaultProjectType;
private bool DefaultShowProjectLocation;
public ReadSettings()
{
try
{
// Read the file and display it line by line.
int count = 0;
string line;
System.IO.StreamReader file = new System.IO.StreamReader("Settings.txt");
while ((line = file.ReadLine()) != null)
{
// Not a setting line, skipping
if (line == "" || line[0] == '#')
continue;
// Found a setting line
switch (count++)
{
case 0:
DefaultProjectDir = line;
break;
case 1:
DefaultProjectType = Int32.Parse(line);
break;
case 2:
DefaultShowProjectLocation = (line == "0" ? false : true);
break;
}
}
file.Close();
}
catch(Exception ex)
{
MessageBox.Show("We got an exception: " + ex, "Error reading Settings.txt");
}
}
public string GetDefaultProjectDir()
{
return DefaultProjectDir;
}
public int GetDefaultProjectType()
{
return DefaultProjectType;
}
public bool GetDefaultShowProjectLocation()
{
return DefaultShowProjectLocation;
}
}
}