private void button3_Click(object sender, EventArgs e) { OpenFileDialog opf = new OpenFileDialog(); textBox3.Clear(); textBox4.Clear(); richTextBox1.Clear(); newDfa = new DfaReader(); opf.InitialDirectory = Assembly.GetExecutingAssembly().Location; opf.RestoreDirectory = true; opf.Filter = "txt files (*.txt)|*.txt"; if (opf.ShowDialog() == DialogResult.OK) { fileName = opf.FileName; } try { myDfa.FillDfa(fileName); newDfa = myDfa.MiniDfa(); richTextBox1.Clear(); textBox4.Text = "Input word with " + newDfa.Alphabet[0] + "," + newDfa.Alphabet[1]; richTextBox1.Text = newDfa.printDfa(); } catch { MessageBox.Show("Something went wrong", "Attention"); } }