Re: SaveFileDialog.ShowDialog() returns Cancel when Yes to overwrite ...



Hello -

I am using the SaveFileDialog out of a *.exe that does not have a GUI
frontend. It is just something quick to run to convert files and
needed to prompt the user for a name and location under which to save
something.

Thanks,
Joe



On Jun 5, 9:04 am, kimiraikkonen <kimiraikkone...@xxxxxxxxx> wrote:
On Jun 5, 3:56 pm, Joe Duchtel <duch...@xxxxxxxxx> wrote:





Hello -

Sorry ... I forgot to take the lDefaultPath out of the code snippet I
posted.  So it did work with .NET 2.0 and 2005?  I actually just
noticed that I am using .NET 1.1 since I have Visual Studio 2003.  I
do have 2.0 installed but that cannot be integrated with 2003.  So
maybe that is the problem?

Thanks a lot!
Joe

On Jun 5, 3:40 am, kimiraikkonen <kimiraikkone...@xxxxxxxxx> wrote:

On Jun 5, 4:49 am, Joe Duchtel <duch...@xxxxxxxxx> wrote:

Hello -

Yep ... I also used the desktop as lDefaultPath but it will just not
work.  I have .NET 2.0 installed.  Maybe that is the problem?
The workaround I found is to just disable the overwrite prompt
(OverwritePrompt = True) and then to a File.Exists() myself to prompt
for the overwrite.  The MsgBox() looks the same to the user will not
notice ... oh well ...

Thanks!
Joe

On Jun 4, 12:43 pm, "Patrice" <http://www.chez.com/scribe/> wrote:

Works fine here using the desktop as lDefaultPath and a .htm file.

I'm using 3.5...

Either :
- some other condition that causes Cancel to be returned (locked file ? non
writable location ?)
- a bug in your version of the framework
- a bug in your own code that makes the return value looks bad when it is
actually good

Good luck.

--
Patrice

"Joe Duchtel" <duch...@xxxxxxxxx> a écrit dans le message de groupe de
discussion :
2dd9a2af-2096-4118-b71e-cbbce552e...@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Hello -

I have the following code to detemine a file name when my application
is saving a file.  The problem is that if the file already exists and
I select the Yes button in the "Do you want to replace" dialog, the
DialogResult is Cancel instead of OK.  Is there something I am
missing?

Dim lSaveFileDialog As New SaveFileDialog

lSaveFileDialog.AddExtension = True
lSaveFileDialog.Filter = "PNG (*.png)|*.png"
lSaveFileDialog.InitialDirectory = lDefaultPath
lSaveFileDialog.OverwritePrompt = True
lSaveFileDialog.Title = "Save As"

Dim lDialogResult As DialogResult = lSaveFileDialog.ShowDialog()

Thanks,
Joe- Hide quoted text -

- Show quoted text -

Hi Joe,
Just tried your code using .NET 2.0 on VB 2005 express:

First, IDefaultPath variable gives "not declared" error as well then i
put a MsgBox to determine which result is returned at the end of code
as follows:

 Dim lSaveFileDialog As New SaveFileDialog

        lSaveFileDialog.AddExtension = True
        lSaveFileDialog.Filter = "PNG (*.png)|*.png"

        lSaveFileDialog.OverwritePrompt = True
        lSaveFileDialog.Title = "Save As"

        Dim lDialogResult As DialogResult =
lSaveFileDialog.ShowDialog()

        MsgBox(lDialogResult.ToString)

and when i confirm to overwrite, Msgbox displays result as "OK".

Anyway, i couldn't understand the logic of your code well, but why
don't you just place SaveFileDialog control on your form if you're not
instantiating it at runtime and if your intention to determine the
dialog result, with more plain code like:

If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
' Returns OK result
MsgBox("OK Clicked")
ElseIf SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.No Then
' Returns No result
 MsgBox("No Clicked")
' ... goes on...
End If

Thanks,

Onur Güzel- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -

I haven't used .NET 1.1 or 2003 ever. I tested using .NET 2.0 with VB
2005 express and OK result is returned after overwrite confirmation.
It may not be a bug in SaveFileDialog class as i hope even in 2003,
but worth to try with 2005 at least and you can see if it solves.

And it'll make things more clear to state what your real goal is with
SaveFileDialog.

Thanks,

Onur Güzel- Hide quoted text -

- Show quoted text -

.