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 EX3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            if (System.IO.File.Exists("d:\\Length.txt"))
            {
                txtLengthOfFile.Text = System.IO.File.ReadAllText("d:\\Length.txt");
            }
        }

        private void btnSelectFile_Click(object sender, EventArgs e)
        {
            string txtData="",finalData="";
            int CharCount = 0;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                txtData = System.IO.File.ReadAllText(openFileDialog1.FileName);
                foreach (char ch in txtData)
                 if (ch !='\r' && ch!='\n')
                    CharCount++;
                finalData=openFileDialog1.FileName+"::::"+CharCount.ToString();
                System.IO.File.AppendAllText("d:\\Length.txt", finalData+"\r\n");
                txtLengthOfFile.Text = System.IO.File.ReadAllText("d:\\Length.txt");
            
            }
        }
    }
}
