Closed akorb closed 6 years ago
This method opens a file, reads each line of the file, and then adds each line as an element of a string. It then closes the file.
I totally understand your worry, but File.ReadAllText
closes the handle too. Actually, it contains almost exactly the same code as yours behind the scenes. See: https://referencesource.microsoft.com/#mscorlib/system/io/file.cs,c193e57831aa94a9,references
A lot of this simplified code takes away the file security that I have in place. For example, the "using" on the File Read automatically closes the file handle when it's finished. What you have works better, but doesn't close the file handle until the program stops.