[Mono-dev] BinaryReader Mono 1.9.1 problem

Mario De Clippeleir mariodc at sydec.be
Thu Jun 12 07:16:44 EDT 2008


 

Hi,

 

The problem is with the ReadChars function. All of a sudden it skips

more than it is supposed to. When I use ReadBytes, it works.

The ReadChars(64) is supposed to be on position 128, but it is on 136.

 

Here are the file and some test code :

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.IO;

 

namespace ConsoleApplication1

{

   class Program

   {

 

       static void Main(string[] args)

       {

           int nrOfColumns = 0;

           Stream memoryStream = File.OpenRead("test.mix");

           BinaryReader reader = new BinaryReader(memoryStream);

           reader.BaseStream.Position = 0;

           Console.Out.WriteLine(reader.BaseStream.Position);

           char[] chars = reader.ReadChars(4);

           Console.Out.WriteLine(reader.BaseStream.Position);

           string identification = new string(chars);

           Console.Out.WriteLine("identification = " + identification);

 

           reader.BaseStream.Position = 40;

           nrOfColumns = reader.ReadInt32();

           Console.Out.WriteLine(reader.BaseStream.Position);

           reader.BaseStream.Position = 60;

           for (int i = 0; i < nrOfColumns; i++)

           {

               reader.ReadInt32();

               Console.Out.WriteLine(reader.BaseStream.Position);

               char[] mixName = reader.ReadChars(64);

               Console.Out.WriteLine(reader.BaseStream.Position);

               //Console.Out.WriteLine(" mixName= " + new

string(mixName));

 

           }

       }

   }

}

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080612/0669e6e1/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.mix
Type: application/octet-stream
Size: 10668 bytes
Desc: test.mix
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080612/0669e6e1/attachment.obj 


More information about the Mono-devel-list mailing list