Below is the final code that I am using now, and this seems to work OK.
If I set either the CreatePrompt or the OverwritePrompt to true, then if the
sub-dialog is displayed, pressing OK return Cabcel as the dialogState value
in this code! Only if I tell the dialog to quietly overwrite files do I get
back the OK result!
-Ken
-----------------------------------------------------------------
String result = null;
//
// Displays a SaveFileDialog for the specified report.
//
SaveFileDialog saveAs = new SaveFileDialog();
saveAs.CreatePrompt = false;
saveAs.OverwritePrompt = false;
saveAs.FileName = @".\" + keReportType.ToString() + ".txt";
saveAs.DefaultExt = "txt";
saveAs.Filter = "Text file|*.txt";
saveAs.InitialDirectory = @".\";
saveAs.Title = "Save a " + keReportType.ToString() + " Report [" +
keReportFormat.ToString() + "]";
DialogResult dialogState = saveAs.ShowDialog();
if (dialogState == DialogResult.OK)
{
result = saveAs.FileName;
}
MessageBox.Show("Result: " + dialogState.ToString());
-----------------------------------------------------------------
"Marcin Grzębski" <mg*******@void.taxussi.com.pl.void> wrote in message
news:c6***********@mamut.aster.pl...
Hi Ken
No, I am attempting to indicate a file name and I get this when the file
already exists -- the save dialog pops up another dialog asking if I
wish to overwrite the file and the return back to my code is "Cancel". I am not
selecting a directory at all.
...then i don't know what is going on???
Did You try to disable OverridePrompt and check File.Exist(...)
in "FileOk" event handler?
That event handler parameter "e", has Cancel property ... so You can
check it in debug mode.
Not any other solution comes to my mind.
Regards
Marcin