generic_cloud_storage_client.MySettings.Load C# (CSharp) 메소드

Load() 공개 정적인 메소드

load if not curropted if curropted file do not hang check the catch block and close the file and load again with defualt settings
public static Load ( ) : MySettings
리턴 MySettings
        public static MySettings Load()
        {
            if (!File.Exists(SettingsFile))
                return DefaultSettings;
                 using(Stream _Stream = File.OpenRead(SettingsFile))

                 {
                     try{

                    XmlSerializer _Object=new XmlSerializer(typeof(MySettings));

                     return (MySettings)_Object.Deserialize(_Stream);
                 }
                     catch (InvalidOperationException)
                     {
                         _Stream.Close();
                         File.Delete(SettingsFile);
                         return DefaultSettings;
                     }

                 }
        }
MySettings