SaveFileDialog

G

Guest

In my VB .Net WinForm app, SaveFileDialog gives me an error msg
"C:\MyFile.txt already exists. Do you want to replace it?"

What I need to do is to append something to an existing file, so I want to
avoid this warning msg. I included "SaveFileDialog.CheckFileExists = False"
in my code, but the warning msg keeps showing up.

Please help, thanks.
 
C

Crouchie1998

Don't use the save file dialog & use stream writer

Dim sw As New IO.StreamWriter(C:\SomeFile.txt", True)

sw.WriteLine("You Text Here")

sw.Flush()

sw.Cloase()
 
H

Herfried K. Wagner [MVP]

John said:
In my VB .Net WinForm app, SaveFileDialog gives me an error msg
"C:\MyFile.txt already exists. Do you want to replace it?"

I am not able to repro this behavior with .NET 1.1, Windows XP Professional
SP2 with a SaveFileDialog placed on a form.
 
S

Samuel R. Neff

Set the OverwritePrompt property to false.

HTH,

Sam


In my VB .Net WinForm app, SaveFileDialog gives me an error msg
"C:\MyFile.txt already exists. Do you want to replace it?"

What I need to do is to append something to an existing file, so I want to
avoid this warning msg. I included "SaveFileDialog.CheckFileExists = False"
in my code, but the warning msg keeps showing up.

Please help, thanks.

B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.
 
H

Herfried K. Wagner [MVP]

Errata:
I am not able to repro this behavior with .NET 1.1, Windows XP
Professional SP2 with a SaveFileDialog placed on a form.

Sorry, I had a bug in my code which leaded to wrong results. The
'OverwritePrompt' property of 'SaveFileDialog' is set to 'True' by default.
By changing its value 'False' prior to showing the dialog the messagebox is
not shown.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top