Skip to content

Instantly share code, notes, and snippets.

@thebitbrine
Last active July 22, 2019 22:55
Show Gist options
  • Save thebitbrine/61c0dd88fc137949c694e98fd45bbb0c to your computer and use it in GitHub Desktop.
Save thebitbrine/61c0dd88fc137949c694e98fd45bbb0c to your computer and use it in GitHub Desktop.
Gets configs.
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