public static bool writeToJSON(string path, ref KolabSettingsContainer target)
 {
     try
     {
         File.WriteAllText(path, JsonConvert.SerializeObject(target, Formatting.Indented));
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine("Failed to write serialized settings: " + e.Message);
         return(false);
     }
 }
 public static bool readFromJSON(string path, ref KolabSettingsContainer target)
 {
     try
     {
         using (var sr = new StreamReader(new FileStream(path, FileMode.Open, FileAccess.Read)))
         {
             target = JsonConvert.DeserializeObject <KolabSettingsContainer>(sr.ReadToEnd());
             return(true);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("Failed to read serialized settings: " + e.Message);
         return(false);
     }
 }
        public MainWindow()
        {
            InitializeComponent();

            //Read JSON
            bool result = readFromJSON(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"..\LocalLow") + "/UlmUniversity/BaseSpoutInteropsettings.json", ref runtimeSettings);

            if (!result)
            {
                runtimeSettings = new KolabSettingsContainer();
                System.Windows.MessageBox.Show("Default settings - please review configuration!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            runtimeSettings.PropertyChanged += RuntimeSettings_PropertyChanged;

            //Read Wordlist
            words = File.ReadAllLines("out.txt");

            this.DataContext = runtimeSettings;
        }