Exemplo n.º 1
0
 private void LoadConfiguration()
 {
     #if DEBUG
     appDir = string.Format(@"C:\Documents and Settings\{0}\Application Data\HomeCollection", Environment.UserName);
     #else
     appDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\HomeCollection";
     #endif
     if (!System.IO.Directory.Exists(appDir))
     {
         System.IO.Directory.CreateDirectory(appDir);
     }
     
     if (System.IO.File.Exists(appDir + @"\HomeCollection.xml"))
     {
         XmlSerializer dsr = new XmlSerializer(typeof(ConfigData));
         System.IO.FileStream openStream = new System.IO.FileStream(appDir + @"\HomeCollection.xml", System.IO.FileMode.Open);
         try
         {
             config = (ConfigData)dsr.Deserialize(openStream);
         }
         finally
         {
             openStream.Close();
         }
     }
     else
     {
         config = new ConfigData();
         config.Defaults();
     }
 }