Exemplo n.º 1
0
 public static void DeSerial(out ClassSetUpProgram set)
 {
     set = new ClassSetUpProgram();
     try
     {
         string     md = Environment.GetFolderPath(Environment.SpecialFolder.Personal);//путь к Документам
         FileStream fs = new FileStream(md + "\\UranSetUp\\" + "settingProg.dat", FileMode.Open);
         try
         {
             BinaryFormatter bf = new BinaryFormatter();
             set = (ClassSetUpProgram)bf.Deserialize(fs);
         }
         catch (SerializationException)
         {
             System.Windows.MessageBox.Show("ошибка");
         }
         finally
         {
             fs.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ошибка серилизации" + ex.ToString());
     }
 }
Exemplo n.º 2
0
        public static void SerialProg(ClassSetUpProgram set)
        {
            string md = Environment.GetFolderPath(Environment.SpecialFolder.Personal);//путь к Документам

            if (Directory.Exists(md + "\\UranSetUp") == false)
            {
                Directory.CreateDirectory(md + "\\UranSetUp");
            }
            BinaryFormatter bf = new BinaryFormatter();

            using (Stream fs = new FileStream(md + "\\UranSetUp\\" + "settingProg.dat", FileMode.Create, FileAccess.Write, FileShare.None))
            {
                bf.Serialize(fs, set);
            }
        }