public void OpenChunk(ChunkType type, ulong length) { if (mOpenChunks.Count() > 0) { ChunkInfo current = mOpenChunks.Peek(); current.SetContainsSubChunks(); current.Consume(length + 16); } mOpenChunks.Push(new ChunkInfo(type, length)); byte[] bytes; bytes = BitConverter.GetBytes((ulong)type); if (BitConverter.IsLittleEndian) bytes.Reverse(); mStream.Write(bytes, 0, 8); // write ChunkType ASCII value bytes = BitConverter.GetBytes(length); if (BitConverter.IsLittleEndian) bytes.Reverse(); mStream.Write(bytes, 0, 8); // write length }