View difference between Paste ID: ruDdjUrW and v7f4eHgx
SHOW: | | - or go back to the newest paste.
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-
        FileStream schreiben;
18+
19-
        StreamWriter weiterschreiben;
19+
20-
        StreamReader weiterlesen;
20+
21-
        FileStream lesen;
21+
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-
            
50+
51-
            schreiben = new FileStream("Baustoffe.txt", FileMode.Create, FileAccess.Write);
51+
52-
            weiterschreiben = new StreamWriter(schreiben);
52+
53-
            weiterschreiben.WriteLine(baustoff.material);
53+
            using (var fs = File.Open("Baustoffe.xml")) {
54-
            weiterschreiben.WriteLine(baustoff.format);
54+
                baustoff = (CBaustoffe)new XmlSerializer(typeof(CBaustoffe)).Deserialize(fs);
55-
            weiterschreiben.WriteLine(baustoff.rohdichte);
55+
            }
56-
            weiterschreiben.WriteLine(baustoff.lamda);
56+
57-
            weiterschreiben.Close();             
57+
58
}