Hi,
I am working on a .NET windows application.
Program writes output data to text files. Following code is used to write Data to text files.
I want to check if the output file with the same name already exists. If exists, want to get confirmation from user whether to append or overwrite.
FileStream fsTXT; StreamWriter rsTXT; string OutputFilename = OutputDir + "\\" + txtFileName.Text + ".txt"; fsTXT = new FileStream(OutputFilename, FileMode.Append, FileAccess.Write); rsTXT = new StreamWriter(fsTXT); //program stores output data in outputrecord string rsTXT.WriteLine(outputrecord); //write the output
I want to change the FileMode.Append parameter at runtime based on the user confirmation. Whether to Append to existing file or Overwrite it?
How to change the FileMode.Append parameter in fsTXT = new FileStream(OutputFilename, FileMode.Append, FileAccess.Write) at runtime based on the confirmation from the user.
Thanks
Ashok