private void saveButton_Click(object sender, EventArgs e) { if (saveFileDialog1.ShowDialog() == DialogResult.OK) { ClassFile obj = new ClassFile(saveFileDialog1.FileName); obj.StringToFile(ResultTextBox.Text); } }