-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStringPropertyFileWriter.cs
executable file
·50 lines (41 loc) · 1.19 KB
/
StringPropertyFileWriter.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
using System;
using System.IO;
namespace TwitchPredictionsBG
{
class StringPropertyFileWriter
{
protected string value;
protected string _configLocation = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\TwitchPredictionsBG\data\";
public StringPropertyFileWriter(string fileName)
{
_configLocation += fileName + ".config";
this.value = load();
}
private void _update(string value)
{
File.WriteAllText(_configLocation, value);
}
public void update(string value)
{
if (this.value == null || !this.value.Equals(value))
{
_update(value);
}
this.value = value;
}
public string load()
{
string value = null;
if (File.Exists(_configLocation))
{
// load config from file, if available
value = File.ReadAllText(_configLocation);
}
else
{
_update(value);
}
return value;
}
}
}