StreamReader returns end of stream after 512 bytes

I am working on some code from Codeshare that jasdev wrote some time back and I have ported it to 4.3 on a G400 and it can create the INI file but has issue when loading it.

At first I had the ReadLine exception but the code on this page fixed that.

https://www.ghielectronics.com/community/forum/topic?id=8577&page=1#msg84980

Now when I try to load the keys and values and step into the code, it gets as far as 512 bytes and then when the code checks to see if at the end of the stream and finishes. The file is approx 4K in size. It loads and looks OK under Windows.

This is the library I am using modified to change the ReadLine exception from above.

https://www.ghielectronics.com/community/codeshare/entry/380

Has anyone seen this issue before?

Well this is interesting. I decided to put back the original ReadLine() that generates the exception and it works now but I am concerned that the exception will return.

Why would the fixed ReadLineEx() call cause the StreamReader to close after only 512 bytes have been read?

I got it working. I changed the code to detect the string as null and now I can read the whole file.