Created
          June 21, 2018 12:40 
        
      - 
      
- 
        Save d630/1de061409cd6c2339adad03abff7d632 to your computer and use it in GitHub Desktop. 
    Windows Forms: r/w file
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | using System; | |
| using System.Collections.Generic; | |
| using System.ComponentModel; | |
| using System.Data; | |
| using System.Drawing; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| using System.Windows.Forms; | |
| using System.IO; | |
| namespace Datei | |
| { | |
| public partial class Form1 : Form | |
| { | |
| public Form1() | |
| { | |
| InitializeComponent(); | |
| } | |
| private void button1_Click(object sender, EventArgs e) | |
| { | |
| FileStream fs = new FileStream("test.dat", FileMode.Create, FileAccess.Write); | |
| StreamWriter sw = new StreamWriter(fs); | |
| sw.WriteLine(textBox1.Text); | |
| sw.Close(); | |
| fs.Close(); | |
| } | |
| private void button2_Click(object sender, EventArgs e) | |
| { | |
| FileStream fs = new FileStream("test.dat", FileMode.Open, FileAccess.Read); | |
| StreamReader sr = new StreamReader(fs); | |
| textBox1.Text = ""; | |
| while (sr.Peek() != -1) | |
| { | |
| textBox1.AppendText(sr.ReadLine() + Environment.NewLine); | |
| } | |
| sr.Close(); | |
| fs.Close(); | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment