Beispiel #1
0
 public static ConfigProperties GetConfigProperties()
 {
     try
     {
         if (!System.IO.Directory.Exists(globalVariables.m_strPropertiesFolder))
         {
             Directory.CreateDirectory(globalVariables.m_strPropertiesFolder);
         }
         var    myProperty = new ConfigProperties();
         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 = (ConfigProperties)mySerializer.Deserialize(myFileStream);
         myFileStream.Close();
         return(myProperty);
     }
     catch (Exception ex)
     {
         return(new ConfigProperties());
     }
 }
Beispiel #2
0
 public static ConfigProperties GetConfigProperties()
 {
     try
     {
         if (!System.IO.Directory.Exists(globalVariables.m_strPropertiesFolder))
         {
             Directory.CreateDirectory(globalVariables.m_strPropertiesFolder);
         }
         var myProperty = new ConfigProperties();
         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 = (ConfigProperties)mySerializer.Deserialize(myFileStream);
         myFileStream.Close();
         return myProperty;
     }
     catch (Exception ex)
     {
         return new ConfigProperties();
     }
 }