Microsoft KB Archive/327213

= BUG: SaveFileDialog object returns &quot;Cancel&quot; whether or not you overwrite an existing file =

Article ID: 327213

Article Last Modified on 1/23/2006

-

APPLIES TO


 * Microsoft .NET Framework 1.1
 * Microsoft Visual Basic .NET 2002 Standard Edition
 * Microsoft Visual Basic .NET 2003 Standard Edition

-



This article was previously published under Q327213



SYMPTOMS
When you call the ShowDialog method of a SaveFileDialog object from the Sub Main procedure, you receive DialogResult.CANCEL whether or not you choose to overwrite an existing file.



RESOLUTION
To avoid this problem, call the ShowDialog method from outside the Sub Main procedure.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
 In Visual Basic .NET, create a new Console Application project. In Project Explorer, right-click References, and then click Add Reference. Click .NET Framework. In the Component Name list, click System.Windows.Forms.Dll, click Select, and then click OK.  Above the Module section of Module 1, enter the following code: Imports System.Windows.Forms   In the Sub Main procedure, enter the following code: Dim myDialog As New SaveFileDialog MessageBox.Show(myDialog.ShowDialog.ToString) </li> On the Debug menu, click Start to run the application.</li> In the Save As dialog box, select any existing file, and then click Save.</li> In the dialog box that prompts you with the question &quot;Do you want to replace the existing file,&quot; click Yes.

Notice that the message box displays the CANCEL DialogResult.</li> Start the application again. Repeat step 8, but in the dialog box that prompts you with the question &quot;Do you want to replace the existing file,&quot; click No.

Notice that the message box displays the CANCEL DialogResult.</li></ol>

Keywords: kbbug kbnofix kbvs2002sp1sweep kbvs2005swept kbvs2005doesnotapply KB327213

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.