コード例 #1
0
ファイル: Utils.cs プロジェクト: vmshis2015/VMSHIS2017
 public static AppProperties GetAppPropertiess()
 {
     try
     {
         if (!Directory.Exists(globalVariables.m_strPropertiesFolder))
         {
             Directory.CreateDirectory(globalVariables.m_strPropertiesFolder);
         }
         var    myProperty = new AppProperties();
         string filePath   = string.Format(@"{0}\{1}.xml", globalVariables.m_strPropertiesFolder,
                                           myProperty.GetType().Name);
         if (!File.Exists(filePath))
         {
             return(myProperty);
         }
         var myFileStream = new FileStream(filePath, FileMode.Open);
         var mySerializer = new XmlSerializer(myProperty.GetType());
         myProperty = (AppProperties)mySerializer.Deserialize(myFileStream);
         myFileStream.Close();
         return(myProperty);
     }
     catch (Exception ex)
     {
         return(new AppProperties());
     }
 }