Last active
July 22, 2019 22:55
-
-
Save thebitbrine/61c0dd88fc137949c694e98fd45bbb0c to your computer and use it in GitHub Desktop.
Gets configs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<KeyValuePair<string, string>> Configurizer(string Path = "configs.conf") | |
{ | |
var Configs = new List<KeyValuePair<string, string>>(); | |
if (System.IO.File.Exists(Path)) | |
{ | |
string[] Lines = System.IO.File.ReadAllLines(Path); | |
foreach (string Line in Lines) | |
{ | |
if (Line.Contains("=")) | |
{ | |
string Key = Line.Remove(Line.IndexOf('=')); | |
string Value = Line.Remove(0, Line.IndexOf('=') + 1); | |
Configs.Add(new KeyValuePair<string, string>(Key, Value)); | |
} | |
} | |
} | |
return Configs; | |
} | |
public void WriteConfigs(List<KeyValuePair<string, string>> Configs, string Path = "configs.conf") | |
{ | |
var String = new StringBuilder(); | |
foreach (var Config in Configs) | |
{ | |
String.AppendLine($"{Config.Key}={Config.Value}"); | |
} | |
System.IO.File.WriteAllText(Path, String.ToString()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment