and my second question is about deleting I had completed deleting process but some time it doesn't work correctly!
        
 
private void button2_Click(object sender, EventArgs e)
        {
           
            List<string> myList = File.ReadAllLines("contact.txt").ToList();  //read
            foreach (DataGridViewRow item in this.dataGridView1.SelectedRows)
            {
                try
                {
                    DialogResult result = MessageBox.Show("are you sure to delete!!", "Warning!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        myList.RemoveAt(item.Index);
                        File.WriteAllLines("contact.txt", myList.ToArray());
                        dataGridView1.Rows.RemoveAt(item.Index);
                    }
                    else
                    {
                        this.dataGridView1.Focus();
                    }
                }
                catch
                {
                    
                    MessageBox.Show("unable to delete", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }