コード例 #1
0
        public static void LoadConfiguration()
        {
            bool loadSuccessful = false;
            if (File.Exists(configLocation))
            {
                using (StreamReader reader = new StreamReader(File.OpenRead(configLocation)))
                {
                    try
                    {
                        string json = reader.ReadLine();
                        instance = JsonConvert.DeserializeObject<Configuration>(json);
                        loadSuccessful = true;
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Configuration Loading Error", e.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }

            if(!loadSuccessful)
            {
                Directory.CreateDirectory(Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "NovelReader"));
                Configuration.Instance.init();
            }
        }