private void addButton_Click(object sender, System.EventArgs e) { if (String.IsNullOrEmpty(textBoxAddUserLDAP.Text)) { MessageBox.Show("Enter user account name please.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { string fileName = "addUser_" + textBoxAddUserLDAP.Text + ".txt"; string[] lines = { "userName="******"password="******"C:\EDI\", fileName); File.WriteAllLines(path, lines); MessageBox.Show(@"File has been created in C:\EDI\", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); } }