コード例 #1
0
        void LoadAppConfig()
        {
            AppConfig locAppConfig;
            DialogResult MBResult;

            do{

                MBResult = DialogResult.Ignore;
                string configFile = Path.Combine(Form1.RegulatedNoiseSettings.GamePath, "AppConfig.xml");
                XmlSerializer serializer; 

                try
                {
                    serializer = new XmlSerializer(typeof(AppConfig)); 
                    using (var myFileStream = new FileStream(configFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        locAppConfig = (AppConfig)serializer.Deserialize(myFileStream);
                        AppConfig = locAppConfig;
                    }
                }
                catch (Exception ex)
                {

                    if (AppConfig == null)
                    {
                        MBResult = Form1.InstanceObject.cmdGamePath_ClickExtracted();

                        if (MBResult == DialogResult.Cancel)
                        {
                            cErr.processError(ex, "Error in LoadAppConfig()");
                        }
                        else if (MBResult == DialogResult.OK)
                            MBResult = DialogResult.Retry;
                        
                    }

                }
            } while (MBResult == DialogResult.Retry);
                
        }
コード例 #2
0
ファイル: GameSettings.cs プロジェクト: nernst/RegulatedNoise
        void LoadAppConfig()
        {
            AppConfig locAppConfig;

            DialogResult MBResult = DialogResult.Ignore;
            string configFile = Path.Combine(Form1.RegulatedNoiseSettings.GamePath, "AppConfig.xml");
            XmlSerializer serializer;

            do{

                try
                {
                    serializer = new XmlSerializer(typeof(AppConfig));
                    using (var myFileStream = new FileStream(configFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        locAppConfig = (AppConfig)serializer.Deserialize(myFileStream);
                        AppConfig = locAppConfig;
                    }
                }
                catch (Exception ex)
                {

                    if (AppConfig == null)
                    {
                        // ignore if it was loaded before
                        cErr.processError(ex, String.Format("Error while loading ED-Appconfig from file <{0}>", configFile));
                    }

                }
            } while (MBResult == DialogResult.Retry);
        }