I am currently trying to find the most efficient way to read text and re-write it into a text file. When I do so, (with a file of 223 KB), I get a result of a 224KB file, appending a few extra sentences to the original file. (These few extra sentences seem to be grabbed from the middle of the file). I cannot seem to find what the problem is. The following is the code I am using:
while(...)
{
writeStream.Write(array, 0, array.Length);
if (read == 0)
break;
}
the third parameter of the ‘write’ method is incorrect. replace it with read and it should work