BUG: BinaryReader.ReadChars() Loses Data When It Reaches End-of-File (318121)
The information in this article applies to:
- Microsoft .NET Framework Class Libraries 1.0
This article was previously published under Q318121 This article references the following .NET Framework Class
Library namespace:
SYMPTOMS If the BinaryReader.ReadChars method reaches the end of the stream, BinaryReader.ReadChars should return all of the characters that it reads.
However, if BinaryReader.ReadChars requests more characters than are available, BinaryReader.ReadChars returns only half of the characters when it reaches the end of
the stream. RESOLUTION If you do not know how many characters remain in the
stream, use one of the following methods to work around this problem:
- Use the StreamReader class instead of the BinaryReader
class, and then use StreamReader.Read(char[],int,int) to read a certain number
of characters from the stream.
- Read the stream as a byte array.
The "More Information" section of this article includes a code
sample that reads the characters as a byte array and then converts the
characters to a string. STATUS This bug was corrected in Microsoft .NET Framework Class
Libraries 1.1.
REFERENCES For more information about a thrown exception, visit the
following MSDN Web site:
Modification Type: | Major | Last Reviewed: | 10/22/2003 |
---|
Keywords: | kbIO kbbug kbFileIO kbKernBase kbpending KB318121 kbAudDeveloper |
---|
|