I have a strange issue. Seems like a few others have had it, but I couldn't find a post on msdn about it.
SaveFileDialog either returns DialogResult.OK or DialogResult.Cancel. The problem is if the file name the user wants tosave the file asalready exists in the current directory, another dialog pops up and asks if the user wants to overwrite. Even if I click "Yes", the SaveFileDialog returns DialogResult.Cancel. Even if this is the correct action C# creators intended to have happen, it goes against all logic and doesn't allow me to know that the user wants to continue on with the save.
On another site's forum, someone responded with the answer " turn SaveFileDialog.OverwritePrompt to false". That will not work for me. I want the user to be warned when they are about to overwrite an existing file, but if they choose to continue I want SaveFileDialog to return DialogResult.OK.
Anyone with a solution to this odd problem I would have never expected to see?
SaveFileDialog saveFileDlg =
new SaveFileDialog();
saveFileDlg.Filter = "Text File (*.txt)|*.txt" ;
saveFileDlg.Title = "Export To Text File";
saveFileDlg.RestoreDirectory =
false;
DialogResult dr = saveFileDlg.ShowDialog();
if (dr != DialogResult.OK)
return;
//Rest of what to do if user chose to save file