System.IO.StreamWriter doesn't write for entire for loop
问题 I am trying to write a long list of numbers to a file in C# but it keeps stopping before the end of the list. For example the following code: System.IO.StreamWriter file = new System.IO.StreamWriter("D:\\test.txt"); for (int i = 0; i < 500; i++) { file.WriteLine(i); } Leaves me with a text file listing the numbers 0 to 431. Changing 500 to 1000 gets me 0 to 840. It just always seems to stop writing before the loop is finished. Outputing the numbers to console as well as file successfully