Okay, I've made a save file dialog, and I've been reading but I personally haven't found much useful information that I understand in creating a save button. I have this as a SaveAs. I'm guessing the save button event is probably very very close to this, but with or without a few things.I get lost in trying to get it to Save over the file I'm working on. All I'm trying to do is remove the save file dialogue box in my save menu button.
` SaveFileDialog fileChooser = new SaveFileDialog();
fileChooser.Title = "Choose Save Location";
fileChooser.Filter = "Text Files (*.txt)|*.txt";
//open dialog, get result
DialogResult result = fileChooser.ShowDialog();
//did they click cancel?
if (result == DialogResult.Cancel)
{
return;
}
//get the file name from the dialog
string strFileName = fileChooser.FileName;
try
{
//save via filestream
//open the new file for write access
if (bCheck == true)
{
output = new FileStream(strFileName,
FileMode.OpenOrCreate, FileAccess.Write);
bCheck = false;
}
else
{
output = new FileStream(strFileName,
FileMode.Append, FileAccess.Write);
}
fileWriter = new StreamWriter(output);
foreach (Employees employees in employee)
{
fileWriter.WriteLine(employees.ToCSVString());
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
//close resources
fileWriter.Close();
output.Close();
}`