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.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace RichTextBox
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- using (var dialog = new SaveFileDialog())
- {
- if (dialog.ShowDialog() == DialogResult.OK && dialog.FileName.Length > 0)
- {
- dialog.DefaultExt = "txt";
- dialog.Filter = "Text files (*.txt)|*.txt";
- richTextBox1.SaveFile(dialog.FileName, RichTextBoxStreamType.UnicodePlainText);
- }
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- using (var dialog = new OpenFileDialog())
- {
- if (dialog.ShowDialog() == DialogResult.OK && dialog.FileName.Length > 0)
- {
- var text = File.ReadAllText(dialog.FileName, Encoding.Unicode);
- richTextBox1.Text = text;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement