Re: Idea for Reader optimisation for reading
From: Tian Min Huang (timhuang_at_online.microsoft.com)
Date: 02/25/04
- Next message: Tian Min Huang: "RE: Debugger not showing up some propertie values in watch or intellisense"
- Previous message: MJ: "Exchange, WebDAV, .NET"
- In reply to: .: "Re: Idea for Reader optimisation for reading"
- Next in thread: .: "Re: Idea for Reader optimisation for reading"
- Reply: .: "Re: Idea for Reader optimisation for reading"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 25 Feb 2004 08:39:16 GMT
Hello,
Thanks for your feedback. I understand your concerns, and now I'd like to
share the following information with you:
1. Did you specify the encoding when creating the BinaryReader? If you did
not specify, it will use UTF8Encoding and I believe that may be the reason
why PeekChar may return -1 on some characters. I suggest you to use ASCII
encoding as the following to check if it works:
BinaryReader r = new BinaryReader(fs, System.Text.Encoding.ASCII);
2. In addition, I do not recommend you use PeekChar to check the EOF
because it also returns -1 when the underlying stream does not support
seeking. Alternatively, I suggest that you can get the length of file and
then get the bytes in a loop. Please refer to the following code snippet:
//--------------------code snippet--------------------
FileInfo fi=new FileInfo(FILE_NAME);
FileStream fs = fi.OpenRead();
BinaryReader r = new BinaryReader(fs);
// Read data
for(int n =0; n<fi.Length; n++)
{
Console.WriteLine(r.ReadByte());
}
.....
//--------------------------end of----------------------
I am standing by for your feedback.
Have a nice day!
Regards,
HuangTM
Microsoft Online Partner Support
MCSE/MCSD
Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
- Next message: Tian Min Huang: "RE: Debugger not showing up some propertie values in watch or intellisense"
- Previous message: MJ: "Exchange, WebDAV, .NET"
- In reply to: .: "Re: Idea for Reader optimisation for reading"
- Next in thread: .: "Re: Idea for Reader optimisation for reading"
- Reply: .: "Re: Idea for Reader optimisation for reading"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|