By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,131 Members | 1,072 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,131 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.