Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- namespace My_NotePad
- {
- public partial class Notepad : Form
- {
- public Notepad()
- {
- InitializeComponent();
- }
- private void SaveButton_Click(object sender, EventArgs e)
- {
- DialogResult myResult = saveFileDialog1.ShowDialog();
- if (myResult == DialogResult.OK)
- {
- StreamWriter FileWriter = new
- StreamWriter(saveFileDialog1.FileName);
- FileWriter.Write(NoteTextBox.Text);
- FileWriter.Close();
- }
- else
- MessageBox.Show("Your note was not saved.");
- }
- private void LoadButton_Click(object sender, EventArgs e)
- {
- NoteTextBox.Clear();
- DialogResult myResult = openFileDialog1.ShowDialog();
- if (myResult == DialogResult.OK)
- {
- StreamReader FileReader = new
- StreamReader(openFileDialog1.FileName);
- NoteTextBox.Text = FileReader.ReadToEnd();
- }
- else
- MessageBox.Show("Your note was not loaded.");
- }
- private void ClearButton_Click(object sender, EventArgs e)
- {
- NoteTextBox.Clear();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement