Advertisement
MBrendecke

Untitled

Feb 6th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.IO;
  10. using System.Windows.Forms;
  11.  
  12. namespace Baustoff_Verzeichnis_mh
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.  
  17.         CBaustoffe baustoff;
  18.  
  19.         public Form1()
  20.         {
  21.             InitializeComponent();
  22.         }
  23.  
  24.         private void Form1_Load(object sender, EventArgs e)
  25.         {            
  26.             baustoff = new CBaustoffe();
  27.             baustoff.material = "KS";
  28.             baustoff.format = "NF";
  29.             baustoff.lamda = 1;
  30.             baustoff.rohdichte = 2;
  31.         }
  32.  
  33.         private void button1_Click(object sender, EventArgs e)
  34.         {
  35.             textBox1.Text = baustoff.material;
  36.             textBox2.Text = baustoff.format;
  37.             textBox3.Text = Convert.ToString(baustoff.rohdichte);
  38.             textBox4.Text = Convert.ToString(baustoff.lamda);
  39.  
  40.             schreibeDatei();
  41.         }
  42.  
  43.  
  44.         public void schreibeDatei()
  45.         {
  46.             using (var fs = File.Create("Baustoffe.xml")) {
  47.                 new XmlSerializer(typeof(CBaustoffe)).Serialize(fs, baustoff);
  48.             }
  49.         }
  50.  
  51.         public void leseDatei()
  52.         {
  53.             using (var fs = File.Open("Baustoffe.xml")) {
  54.                 baustoff = (CBaustoffe)new XmlSerializer(typeof(CBaustoffe)).Deserialize(fs);
  55.             }
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement