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

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {


            String ten = textBox1.Text;
            String sodienthoai = maskedTextBox1.Text;
            Boolean a1 = File.Exists(@"D:\\nghiadaica1.txt");
            if (a1 == true)
            {
                String[] ab = File.ReadAllLines(@"D:\\nghiadaica1.txt");
                StreamWriter a = File.CreateText(@"D:\\nghiadaica1.txt");
                for (int i = 0; i < ab.Length; i++)
                {
                    a.WriteLine(ab[i]);
                    a.Flush();
                }
                a.WriteLine("ten : " + ten + "\t" + "\t" + "so dien thoai " + sodienthoai);
                a.Flush();
                a.Close();
            }
            else
            {
                StreamWriter a = File.CreateText(@"D:\\nghiadaica1.txt");
                a.WriteLine("ten : " + ten + "\t" + "so dien thoai " + sodienthoai);
                a.Flush();
                a.Close(); ;
            }
            

        }
    }
}
