Hi all i am using a save dialog box to save a text file to a loction becuse i cant hard code in the driectory. My problem is that i can save the first line of text that i write to the file but i want then to be able to save save another line of text but it ask me to over write the file is there any way to get around this so that i can save as many lines as i want .
My code:
private void btnSave_Click(object sender, EventArgs e)
{
Stream myStream;
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
if ((myStream = saveFileDialog1.OpenFile()) != null)
{
firstName = txtFirstName.Text;
lastName = txtLastName.Text;
phoneNoArea = Convert.ToInt32(txtAreaCode.Text);
phoneNo = Convert.ToInt32(txtPhoneNumber.Text);
birthMonth = txtBirthMonth.Text;
birthDay = Convert.ToInt32(txtDateOfBirth.Text);
Writer.WriteLine(firstName + Record + lastName + Record + phoneNoArea + Record + phoneNo + Record + birthMonth + Record + birthDay + Record);
// Clear the Text Boxes
txtFirstName.Clear();
txtLastName.Clear();
txtAreaCode.Clear();
txtPhoneNumber.Clear();
txtBirthMonth.Clear();
txtDateOfBirth.Clear();
MessageBox.Show("File Saved");
myStream.Close();
}
}
}