Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Does System.IO.File.WriteAllLines() overwrite the target file if it already exists?

e.g. you have it set for C:/Users/Public/Documents/writefile.txt, but writefile.txt already exists. Does it overwrite writefile.txt and make a new one based on its own arguments?

2 Answers

Relevance
  • 4 years ago

    Yes, it does. This function creates a new file, writes all lines to the file, and then closes the file.

  • 4 years ago

    Yes it does. It is the programmer's responsibility to check to see if the file already exists, and if so, warn the user and ask the user if the program should continue and overwrite the target file.

Still have questions? Get your answers by asking now.