neverwinter neverwinter - 1 month ago 13
C# Question

StreamWriter 64512 character limitation

I am using stringbuilder to collect some strings in my code. At the of that code my stringbuilder has more than 100000 chars.

But writeline function writes only first 64512 chars in stringBuilder. When I debugged the code I saw that stringbuilder is able to return all of 100000 chars, but streamwriter can't handle these all charachters. My stringbuilder variable is

sbPmml
in the code below.

System.IO.StreamWriter file = new System.IO.StreamWriter(txtDP.Text + "\\" + txtPmmlName.Text + ".txt");
file.WriteLine(sbPmml.ToString());


How can I print all these chars to file via stringbuilder wihtout spliting the stringbuilder a few pieces?

Answer

I added the code below. It worked for me

file.AutoFlush = true;