-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfigFile.cs
executable file
·56 lines (48 loc) · 1.6 KB
/
ConfigFile.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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GenerateEXamlTool
{
internal class ConfigFile
{
static internal string XamlFilePath
{
get;
set;
}
static internal string AssemblyPath
{
get;
set;
}
static internal void Load()
{
string currentExePath = Process.GetCurrentProcess().MainModule.FileName;
int lastIndex = currentExePath.LastIndexOf('\\');
currentExePath = currentExePath.Substring(0, lastIndex);
if (!File.Exists(currentExePath + @"\config.ini"))
{
var stream = File.Create(currentExePath + @"\config.ini");
stream.Close();
}
var contents = File.ReadAllText(currentExePath + @"\config.ini").Split('\n');
if (2 <= contents.Length)
{
AssemblyPath = contents[0];
XamlFilePath = contents[1];
}
}
static internal void Save()
{
string currentExePath = Process.GetCurrentProcess().MainModule.FileName;
int lastIndex = currentExePath.LastIndexOf('\\');
currentExePath = currentExePath.Substring(0, lastIndex);
string content = String.Format("{0}\n{1}", AssemblyPath, XamlFilePath);
File.WriteAllText(currentExePath + @"\config.ini", content);
}
}
}