Exemple #1
0
        public void LoadSettings()
        {
            StreamReader sr = null;
            try
            {
                // 環境設定ファイルのPATH設定
                string AppPath = System.AppDomain.CurrentDomain.BaseDirectory;
                string SettingPath = AppPath + fileName;

                if (File.Exists(SettingPath))
                {
                    // 環境設定データ読込
                    sr = new StreamReader(SettingPath, Encoding.Default);
                    XmlSerializer serializer = new XmlSerializer(typeof(Settings));
                    instance = (Settings)(serializer.Deserialize(sr));
                }
                else
                {
                    // 環境設定ファイルが存在しない時は作成
                    SaveSettings();
                }

            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Write(ex);
            }
            finally
            {
                if (sr != null) sr.Close();
            }
        }