473,756 Members | 2,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 .InitialDirecto ry = lDefaultPath
lSaveFileDialog .OverwritePromp t = True
lSaveFileDialog .Title = "Save As"

Dim lDialogResult As DialogResult = lSaveFileDialog .ShowDialog()

Thanks,
Joe
Jun 27 '08 #1
8 11625
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" <du*****@gmail. coma écrit dans le message de groupe de
discussion :
2d************* *************** **...legroups .com...
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 .InitialDirecto ry = lDefaultPath
lSaveFileDialog .OverwritePromp t = True
lSaveFileDialog .Title = "Save As"

Dim lDialogResult As DialogResult = lSaveFileDialog .ShowDialog()

Thanks,
Joe

Jun 27 '08 #2
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
(OverwritePromp t = 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...@gmail. coma écrit dans le message de groupe de
discussion :
2dd9a2af-2096-4118-b71e-cbbce552e...@d1 g2000hsg.google groups.com...
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 .InitialDirecto ry = lDefaultPath
lSaveFileDialog .OverwritePromp t = True
lSaveFileDialog .Title = "Save As"
Dim lDialogResult As DialogResult = lSaveFileDialog .ShowDialog()
Thanks,
Joe- Hide quoted text -

- Show quoted text -
Jun 27 '08 #3
On Jun 5, 4:49 am, Joe Duchtel <duch...@gmail. comwrote:
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
(OverwritePromp t = 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...@gmail. coma écrit dans le message de groupe de
discussion :
2dd9a2af-2096-4118-b71e-cbbce552e...@d1 g2000hsg.google groups.com...
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 .InitialDirecto ry = lDefaultPath
lSaveFileDialog .OverwritePromp t = 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 .OverwritePromp t = True
lSaveFileDialog .Title = "Save As"

Dim lDialogResult As DialogResult =
lSaveFileDialog .ShowDialog()

MsgBox(lDialogR esult.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.D ialogResult.OK Then
' Returns OK result
MsgBox("OK Clicked")
ElseIf SaveFileDialog1 .ShowDialog = Windows.Forms.D ialogResult.No Then
' Returns No result
MsgBox("No Clicked")
' ... goes on...
End If
Thanks,

Onur Güzel

Jun 27 '08 #4
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.. .@gmail.comwrot e:
On Jun 5, 4:49 am, Joe Duchtel <duch...@gmail. comwrote:


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
(OverwritePromp t = 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 itis
actually good
Good luck.
--
Patrice
"Joe Duchtel" <duch...@gmail. coma écrit dans le message de groupe de
discussion :
2dd9a2af-2096-4118-b71e-cbbce552e...@d1 g2000hsg.google groups.com...
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 .InitialDirecto ry = lDefaultPath
lSaveFileDialog .OverwritePromp t = 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 .OverwritePromp t = True
* * * * lSaveFileDialog .Title = "Save As"

* * * * Dim lDialogResult As DialogResult =
lSaveFileDialog .ShowDialog()

* * * * MsgBox(lDialogR esult.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.D ialogResult.OK Then
' Returns OK result
MsgBox("OK Clicked")
ElseIf SaveFileDialog1 .ShowDialog = Windows.Forms.D ialogResult.No Then
' Returns No result
*MsgBox("No Clicked")
' ... goes on...
End If

Thanks,

Onur Güzel- Hide quoted text -

- Show quoted text -
Jun 27 '08 #5
On Jun 5, 3:56*pm, Joe Duchtel <duch...@gmail. comwrote:
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.. .@gmail.comwrot e:
On Jun 5, 4:49 am, Joe Duchtel <duch...@gmail. comwrote:
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
(OverwritePromp t = 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...@gmail. coma écrit dans le message de groupe de
discussion :
2dd9a2af-2096-4118-b71e-cbbce552e...@d1 g2000hsg.google groups.com...
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 .InitialDirecto ry = lDefaultPath
lSaveFileDialog .OverwritePromp t = 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 .OverwritePromp t = True
* * * * lSaveFileDialog .Title = "Save As"
* * * * Dim lDialogResult As DialogResult =
lSaveFileDialog .ShowDialog()
* * * * MsgBox(lDialogR esult.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.D ialogResult.OK Then
' Returns OK result
MsgBox("OK Clicked")
ElseIf SaveFileDialog1 .ShowDialog = Windows.Forms.D ialogResult.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
Jun 27 '08 #6
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.. .@gmail.comwrot e:
On Jun 5, 3:56*pm, Joe Duchtel <duch...@gmail. comwrote:


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.. .@gmail.comwrot e:
On Jun 5, 4:49 am, Joe Duchtel <duch...@gmail. comwrote:
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
(OverwritePromp t = 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...@gmail. coma écrit dans le message de groupe de
discussion :
2dd9a2af-2096-4118-b71e-cbbce552e...@d1 g2000hsg.google groups.com....
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 .InitialDirecto ry = lDefaultPath
lSaveFileDialog .OverwritePromp t = 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 .OverwritePromp t = True
* * * * lSaveFileDialog .Title = "Save As"
* * * * Dim lDialogResult As DialogResult =
lSaveFileDialog .ShowDialog()
* * * * MsgBox(lDialogR esult.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.D ialogResult.OK Then
' Returns OK result
MsgBox("OK Clicked")
ElseIf SaveFileDialog1 .ShowDialog = Windows.Forms.D ialogResult.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 -
Jun 27 '08 #7
That is the problem, that it is a console application. Look at this link and
try the work arround.

http://support.microsoft.com/kb/327213
"Joe Duchtel" wrote:
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.. .@gmail.comwrot e:
On Jun 5, 3:56 pm, Joe Duchtel <duch...@gmail. comwrote:


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.. .@gmail.comwrot e:
On Jun 5, 4:49 am, Joe Duchtel <duch...@gmail. comwrote:
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
(OverwritePromp t = 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...@gmail. coma écrit dans le message de groupe de
discussion :
2dd9a2af-2096-4118-b71e-cbbce552e...@d1 g2000hsg.google groups.com....
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 .InitialDirecto ry = lDefaultPath
lSaveFileDialog .OverwritePromp t = 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 .OverwritePromp t = True
lSaveFileDialog .Title = "Save As"
Dim lDialogResult As DialogResult =
lSaveFileDialog .ShowDialog()
MsgBox(lDialogR esult.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.D ialogResult.OK Then
' Returns OK result
MsgBox("OK Clicked")
ElseIf SaveFileDialog1 .ShowDialog = Windows.Forms.D ialogResult.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 -

Jun 27 '08 #8
Hello -

Wow ... so I found a bug!

I tried the workaround but even when calling the ShowDialog() from a
function that is called from Main(), it did not work properly. So I
will stick with my own overwrite protection for now.

Thanks a lot!
Joe

On Jun 5, 11:52*am, Family Tree Mike
<FamilyTreeM... @discussions.mi crosoft.comwrot e:
That is the problem, that it is a console application. *Look at this link and
try the work arround.

http://support.microsoft.com/kb/327213

"Joe Duchtel" wrote:
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.. .@gmail.comwrot e:
On Jun 5, 3:56 pm, Joe Duchtel <duch...@gmail. comwrote:
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.. .@gmail.comwrot e:
On Jun 5, 4:49 am, Joe Duchtel <duch...@gmail. comwrote:
Hello -
Yep ... I also used the desktop as lDefaultPath but it will justnot
work. *I have .NET 2.0 installed. *Maybe that is the problem?
The workaround I found is to just disable the overwrite prompt
(OverwritePromp t = True) and then to a File.Exists() myself toprompt
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 badwhen it is
actually good
Good luck.
--
Patrice
"Joe Duchtel" <duch...@gmail. coma écrit dans le message degroupe de
discussion :
2dd9a2af-2096-4118-b71e-cbbce552e...@d1 g2000hsg.google groups.com....
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 alreadyexists 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 .InitialDirecto ry = lDefaultPath
lSaveFileDialog .OverwritePromp t = 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 .OverwritePromp t = True
* * * * lSaveFileDialog .Title = "Save As"
* * * * Dim lDialogResult As DialogResult =
lSaveFileDialog .ShowDialog()
* * * * MsgBox(lDialogR esult.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'renot
instantiating it at runtime and if your intention to determine the
dialog result, with more plain code like:
If SaveFileDialog1 .ShowDialog = Windows.Forms.D ialogResult.OK Then
' Returns OK result
MsgBox("OK Clicked")
ElseIf SaveFileDialog1 .ShowDialog = Windows.Forms.D ialogResult.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 -- Hide quoted text -

- Show quoted text -
Jun 27 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2728
by: GATMAN | last post by:
Dim f As New frmWeb f.ShowDialog(Me) f.Dispose() Annytime i call a diffrent form from my main form using showdialog, i get an exception eror thrown when i close the form, but when i use f.show i don't get any errors, i need the knew form to keep the focus until closed. thank you
1
7783
by: James G. Beldock | last post by:
I have seen the following behavior: when issuing a Page.FindControl() for a control which exists in an item template (from within an ItemDataBound() event, for example), I get nulls back regularly. Has anyone seen this before? It's pretty aggravating to have to iterate through the controls in each grid cell to find the ones I need, especially since finding those cells is not always easy. Here's my ItemDataBound() handler: private void...
4
3741
by: Sacha Korell | last post by:
First of all, sorry for cross-posting, but this newsgroup is much busier than "aspnet.mobile". I'm trying to create a portal page that redirects depending on the device that is connecting. When I use Request.Browser("IsMobileDevice"), it returns false when connecting with my iPAQ 2215 (and other Windows Mobile 2003 devices), although HTTPBrowserCapabilities "Platform" returns "WinCE".
2
4252
by: csharper | last post by:
Why does Guid.GetHashcode() returns 0 when instantiated with Guid.Empty ?
1
1306
by: amfr | last post by:
This code always returns a ValueError when it is not supposed to: i = rest.rfind('?') Error: ValueError: need more than 0 values to unpack rfind is not supposed to generate an erro, just return -1. Any ideas?
2
1461
by: wishsand | last post by:
Here is the XML in a file: <?xml version='1.0' encoding='utf-8' ?> <bkxml version='1.0' xmlns='http://www.w3.org/2003/03/bkxml'> <model> <data name="angle" expr="100"></data> <data name="sample" expr="200"></data> </model> </bkxml>
0
1825
by: alexh1000 | last post by:
When I insert the FlexGrid control in a dialog (using controls toolbar) the dialog fails to open on program execution(DoModal returns a -1). If I remove the FlexGrid from the dialog, the dialog opens so it is definitely a flexgrid related issue. This is using VC++ 6.0 I did not change any of the default FlexGrid properties yet. Thanks
1
1355
by: alexh1000 | last post by:
When I insert the FlexGrid control in a dialog (using controls toolbar) the dialog fails to open on program execution (DoModal returns a -1). If I remove the FlexGrid from the dialog, the dialog opens so it is definitely a flexgrid related issue. This is using VC++ 6.0 I did not change any of the default FlexGrid properties yet. Thanks
2
14677
by: Uldis Bojars | last post by:
Hi All, I have encountered problems with JS RegExp.exec() and can't find what is the problem. Could you help me? formRequest is a function that extracts some information from XMLHTTPRequest response. A very strange effect (and I can't find where I've done something wrong) is that regexp matches in this function fail on every second call.
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10034
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9843
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.