So I have been struggling to create a "Save" button in my .NET application. I seem to be doing everything correctly according to my research. I have been referring to this article as a main source: http://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog.aspx
The following is my method code in C#:
private void save2(object A_0, EventArgs A_1)
{
Stream stream = new Stream();
savefile2 = new SaveFileDialog();
savefile2.InitialDirectory = @"C:\Program Files\Folder\";
savefile2.Filter = "Text files (*.txt)|*.txt|Word files (*.doc)|*.doc";
savefile2.FilterIndex = 1;
savefile2.FileName = "*.txt";
savefile2.Title = "Save Box Text";
savefile2.OverwritePrompt = true;
if (savefile2.ShowDialog() == DialogResult.OK)
{
stream = savefile2.OpenFile();
if (stream != null)
{
stream.Close();
}
}
}
When running the program, I click the "Save" button to see if it will open a dialog box, and it produces the following error:
"Instances of abstract classes cannot be created."
However, I am not using any abstract classes. All the classes are within the .NET framework. So, I'm stuck. Any help would be appreciated.