dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pnet-developers] [bug #14339] BinaryReader doesn't read specified amoun


From: Peter Flaig
Subject: [Pnet-developers] [bug #14339] BinaryReader doesn't read specified amount of bytes
Date: Tue, 30 Aug 2005 12:00:59 +0000
User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 1.0.3705)

URL:
  <http://savannah.gnu.org/bugs/?func=detailitem&item_id=14339>

                 Summary: BinaryReader doesn't read specified amount of bytes
                 Project: DotGNU Portable.NET
            Submitted by: fliege
            Submitted on: Di 30.08.2005 um 12:00
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open

    _______________________________________________________

Details:

The method 'byte[] ReadBytes(int count)' of System.IO.BinaryReader doesn't
read the specified amount of bytes although the end of the stream isn't
reached.

In MS.NET there is a while loop to read the specified amount of bytes until
the end of the stream is reached.

For DotGNU the method should look like this:
public virtual byte[] ReadBytes(int count)
{
        byte[] buffer;
        int result;
        if(count < 0)
        {
                throw new ArgumentOutOfRangeException("count", 
"ArgRange_NonNegative"));
        }
        buffer = new byte [count];
        
        do
        {
                int num2 = Read(buffer, result, count);
                if (num2 == 0)
                {
                        break;
                }
                result += num2;
                count -= num2;
        }
        while (count > 0);

        if (result != buffer.Length)
        {
                byte[] newBuffer = new byte [result];
                Array.Copy(buffer, newBuffer, result);
                return newBuffer;
        }
        else
        {
                return buffer;
        }
}






    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?func=detailitem&item_id=14339>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.gnu.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]