コード例 #1
0
ファイル: frmSchemeEditor.cs プロジェクト: ashsvis/RemXcs
 public void LoadFile(string FileName)
 {
     if (FileName != "")
     {
         CurrFileName = FileName;
         this.Text    = CurrFileName;
         FileStream fs = new FileStream(FileName, FileMode.Open);
         try
         {
             BinaryFormatter formatter = new BinaryFormatter();
             DrawsList = (AllDraws)formatter.Deserialize(fs);
             foreach (Draws drw in DrawsList)
             {
                 drw.Initialize();
             }
             FileChanged = false;
         }
         catch (SerializationException e)
         {
             Console.WriteLine("Failed to deserialize. Reason: " + e.Message);
             throw;
         }
         finally
         {
             fs.Close();
         }
         this.Refresh();
     }
 }
コード例 #2
0
ファイル: frmSchemeEditor.cs プロジェクト: ashsvis/RemXcs
 public void SaveFileAs(string FileName)
 {
     CurrFileName = FileName;
     this.Text    = CurrFileName;
     using (FileStream fs = new FileStream(FileName, FileMode.Create))
     {
         BinaryFormatter formatter = new BinaryFormatter();
         //SoapFormatter formatter = new SoapFormatter();
         AllDraws alldrw = new AllDraws();
         try
         {
             foreach (Draws drw in DrawsList)
             {
                 alldrw.Add(drw);
             }
             formatter.Serialize(fs, alldrw);
             FileChanged = false;
         }
         catch (SerializationException e)
         {
             Console.WriteLine("Failed to serialize. Reason: " + e.Message);
             throw;
         }
     }
 }