473,378 Members | 1,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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.InitialDirectory = lDefaultPath
lSaveFileDialog.OverwritePrompt = True
lSaveFileDialog.Title = "Save As"

Dim lDialogResult As DialogResult = lSaveFileDialog.ShowDialog()

Thanks,
Joe
Jun 27 '08 #1
8 11560
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**********************************...oglegroups.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.InitialDirectory = lDefaultPath
lSaveFileDialog.OverwritePrompt = 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
(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...@gmail.coma écrit dans le message de groupe de
discussion :
2dd9a2af-2096-4118-b71e-cbbce552e...@d1g2000hsg.googlegroups.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.InitialDirectory = lDefaultPath
lSaveFileDialog.OverwritePrompt = 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
(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...@gmail.coma écrit dans le message de groupe de
discussion :
2dd9a2af-2096-4118-b71e-cbbce552e...@d1g2000hsg.googlegroups.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.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

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.comwrote:
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
(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 itis
actually good
Good luck.
--
Patrice
"Joe Duchtel" <duch...@gmail.coma écrit dans le message de groupe de
discussion :
2dd9a2af-2096-4118-b71e-cbbce552e...@d1g2000hsg.googlegroups.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.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 -
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.comwrote:
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
(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...@gmail.coma écrit dans le message de groupe de
discussion :
2dd9a2af-2096-4118-b71e-cbbce552e...@d1g2000hsg.googlegroups.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.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
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.comwrote:
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.comwrote:
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
(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...@gmail.coma écrit dans le message de groupe de
discussion :
2dd9a2af-2096-4118-b71e-cbbce552e...@d1g2000hsg.googlegroups.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.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 -
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.comwrote:
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.comwrote:
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
(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...@gmail.coma écrit dans le message de groupe de
discussion :
2dd9a2af-2096-4118-b71e-cbbce552e...@d1g2000hsg.googlegroups.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.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 -

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.microsoft.comwrote:
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.comwrote:
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.comwrote:
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
(OverwritePrompt = 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...@d1g2000hsg.googlegroups.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.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'renot
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 -- 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
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...
1
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...
4
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. ...
2
by: csharper | last post by:
Why does Guid.GetHashcode() returns 0 when instantiated with Guid.Empty ?
1
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...
2
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"...
0
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...
1
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...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.