-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathEditorIni.cs
44 lines (40 loc) · 1.37 KB
/
EditorIni.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OpenXP
{
class EditorIni
{
public string LastProjectDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
private string filepath;
public EditorIni()
{
filepath = System.IO.Path.Combine(Program.GetEditorDirectory(), "OpenXP.ini");
try
{
string ini = System.IO.File.ReadAllText(filepath);
string[] lines = ini.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
foreach (string s in lines)
{
if (s.Contains("="))
{
string[] sy = s.Split(new[] { "=" }, StringSplitOptions.None);
if (sy.Length > 1)
{
if (sy[0].Trim().ToLower() == "lastproject") LastProjectDirectory = sy[1].Trim();
}
}
}
}
catch (Exception e) { Console.WriteLine(e.Message); }
}
public void Save()
{
string file = "[Editor]\r\nLastProject=" + LastProjectDirectory;
System.IO.File.WriteAllText(filepath, file);
}
}
}