luk_per

delegaty_okienkowo

Apr 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  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.Windows.Forms;
  10. using System.IO;
  11.  
  12. namespace zad_3
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         public Form1()
  17.         {
  18.             InitializeComponent();
  19.            
  20.         }
  21.         static FileStream fs;
  22.         static StreamWriter sw;
  23.         public delegate void Del(string str, string str2,decimal dec);
  24.         public delegate void Del2();
  25.         Del HandlerZapis = delegate (string imie, string nazwisko, decimal rok)
  26.         {
  27.             fs = new FileStream("D:\\!!!Studia\\Semestr 4\\Moje\\Informatyka\\Labki\\lab_7\\message3.txt", FileMode.Append, FileAccess.Write);
  28.             sw = new StreamWriter(fs);
  29.  
  30.  
  31.  
  32.             sw.WriteLine(imie + " " + nazwisko + " " + " " + rok);
  33.             sw.Flush();
  34.             sw.Close();
  35.             fs.Close();
  36.         };
  37.  
  38.  
  39.         Del2 HandlerOdczyt = delegate ()
  40.         {
  41.             StreamReader sr = new StreamReader("D:\\!!!Studia\\Semestr 4\\Moje\\Informatyka\\Labki\\lab_7\\message3.txt");
  42.             String line = sr.ReadToEnd();
  43.             sr.Close();
  44.             MessageBox.Show(line);
  45.  
  46.  
  47.         };
  48.  
  49.         private void PrzyciskZapisz_Click(object sender, EventArgs e)
  50.         {
  51.             HandlerZapis(Imie.Text, Nazwisko.Text, Rok.Value);
  52.         }
  53.  
  54.  
  55.         private void PrzyciskOdczyt_Click_1(object sender, EventArgs e)
  56.         {
  57.             HandlerOdczyt();
  58.         }
  59.  
  60.  
  61.     }
  62. }
Add Comment
Please, Sign In to add comment