using System;
using System.Windows.Forms;

namespace _11_4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            openFileDialog1.Title = "Open";
            openFileDialog1.FileName = string.Empty;
            openFileDialog1.InitialDirectory = "C:\\";
            openFileDialog1.Filter = "Documents Files (*.rtf)|*.rtf|All Files (*.*)|*.*";
            openFileDialog1.FilterIndex = 1;
            //-----------------------------------------------------
            saveFileDialog1.InitialDirectory = "C:\\";
            saveFileDialog1.DefaultExt = "rtf";
            saveFileDialog1.FileName = string.Empty;
            saveFileDialog1.OverwritePrompt = true;
            saveFileDialog1.Title = "Save As";
            saveFileDialog1.Filter = "rtf file (*.rtf)|*.rtf";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.FileName = string.Empty;
            //-----------------------------------------------------
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
                richTextBox1.LoadFile(openFileDialog1.FileName);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            saveFileDialog1.FileName = string.Empty;
            //-----------------------------------------------------
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                richTextBox1.SaveFile(saveFileDialog1.FileName);
        }
    }
}