Skip to content

Instantly share code, notes, and snippets.

@edg-l
Last active March 1, 2017 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edg-l/94833ca935262888bcb85a9285d1239f to your computer and use it in GitHub Desktop.
Save edg-l/94833ca935262888bcb85a9285d1239f to your computer and use it in GitHub Desktop.
public class ConfigFile
{
public int someconfig = 10;
public static ConfigFile Read(string path)
{
if (!File.Exists(path))
{
ConfigFile config = new ConfigFile();
File.WriteAllText(path, JsonConvert.SerializeObject(config, Formatting.Indented));
return config;
}
return JsonConvert.DeserializeObject<ConfigFile>(File.ReadAllText(path));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment