What is the recommended approach to get the best performance when we need to create text files bigger than 10MB.
There are multiple sections in the code that need to write stuff to a single file. This means a lot of text lines.
Option #1: (This logic will be called at several times)
- Create a StreamWriter instance
- Write some lines (according to some business logic)
- Close the StreamWriter instance
Option #2:
- Create a StreamWriter at the begining of the program
- Write all of the lines from diferent sections of the code.
- Close the StreamWriter at the very end when nothing else need to be written.
Option #3: Any other?
Remember the output file could be bigger than 10MB.