overwrite dialog for streamwriter?

  • Thread starter Thread starter r_poetic
  • Start date Start date
R

r_poetic

Hello,
I am using StreamWriter, and I want to check if the file I intend to
write to already exists and to have the choice to continue or bail
out. I know that File.Exists(name) will check whether the file
already exists. But I can't spot a built-in way to generate a dialog
for the user to continue and begin writing or to quit. I guess I
might write a specific dialog box for this....? Thanks for
suggestions.
 
Hello,
I am using StreamWriter, and I want to check if the file I intend to
write to already exists and to have the choice to continue or bail
out.  I know that File.Exists(name)  will check whether the file
already exists.  But I can't spot a built-in way to generate a dialog
for the user to continue and begin writing or to quit.  I guess I
might write a specific dialog box for this....?  Thanks for
suggestions.

Hi,

I'm not very sure of what you want. you can have a construction like:

if ( File.Exist( ...) )
if ( DialogResult.Yes == MessageBox.Show("are you sure you want to
overwrite. ...."))
{
// do it
}

Also remember that you cannot be 100% sure that the file does not
exist as it can be created between the File.Exist and when you use it.
 
Back
Top