using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

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

        private void btnOpenFile_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                lblPath.Text = openFileDialog1.FileName;
                 txtFile.Text= System.IO.File.ReadAllText(openFileDialog1.FileName);
                 btnSave.Enabled = true;
                 txtFile.Enabled = true;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            btnSave.Enabled = false;
            txtFile.Enabled = false;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            System.IO.File.WriteAllText(openFileDialog1.FileName, txtFile.Text);
            MessageBox.Show("ذخیره اطلاعات با موفقیت انجام شد", "ثبت و بروز رسانی", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

      
    }
}
