Advertisement
SuperLemrick

Mark's Notepad

Dec 27th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 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.Windows.Forms;
  9. using System.IO;
  10.  
  11. namespace My_NotePad
  12. {
  13.     public partial class Notepad : Form
  14.     {
  15.         public Notepad()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void SaveButton_Click(object sender, EventArgs e)
  21.         {
  22.             DialogResult myResult = saveFileDialog1.ShowDialog();
  23.  
  24.             if (myResult == DialogResult.OK)
  25.             {
  26.                 StreamWriter FileWriter = new
  27.                                           StreamWriter(saveFileDialog1.FileName);
  28.  
  29.                 FileWriter.Write(NoteTextBox.Text);
  30.  
  31.                 FileWriter.Close();
  32.             }
  33.             else
  34.  
  35.                 MessageBox.Show("Your note was not saved.");
  36.         }
  37.  
  38.         private void LoadButton_Click(object sender, EventArgs e)
  39.         {
  40.             NoteTextBox.Clear();
  41.  
  42.             DialogResult myResult = openFileDialog1.ShowDialog();
  43.  
  44.             if (myResult == DialogResult.OK)
  45.             {
  46.                 StreamReader FileReader = new
  47.                 StreamReader(openFileDialog1.FileName);
  48.  
  49.                 NoteTextBox.Text = FileReader.ReadToEnd();
  50.             }
  51.             else
  52.                 MessageBox.Show("Your note was not loaded.");
  53.         }
  54.  
  55.         private void ClearButton_Click(object sender, EventArgs e)
  56.         {
  57.             NoteTextBox.Clear();
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement