当前位置: 首页>>代码示例>>C#>>正文


C# IO.BinaryReader类代码示例

本文整理汇总了C#中System.IO.BinaryReader的典型用法代码示例。如果您正苦于以下问题:C# BinaryReader类的具体用法?C# BinaryReader怎么用?C# BinaryReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BinaryReader类属于System.IO命名空间,在下文中一共展示了BinaryReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadTXFNChunk

        private void ReadTXFNChunk(BinaryReader bin, BlizzHeader chunk)
        {
            //List of BLP filenames
            var blpFilesChunk = bin.ReadBytes((int)chunk.Size);

            var str = new StringBuilder();

            for (var i = 0; i < blpFilesChunk.Length; i++)
            {
                if (blpFilesChunk[i] == '\0')
                {
                    if (str.Length > 1)
                    {
                        str.Replace("..", ".");
                        str.Append(".blp"); //Filenames in TEX dont have have BLP extensions
                        if (!CASC.FileExists(str.ToString()))
                        {
                            new WoWFormatLib.Utils.MissingFile(str.ToString());
                        }
                    }
                    str = new StringBuilder();
                }
                else
                {
                    str.Append((char)blpFilesChunk[i]);
                }
            }
        }
开发者ID:Ser0ja,项目名称:WoWFormatTest,代码行数:28,代码来源:TEXReader.cs

示例2: GetImageBytes

 protected byte[] GetImageBytes()
 {
     Stream fs = FileUpload.PostedFile.InputStream;
     BinaryReader br = new BinaryReader(fs);
     Byte[] bytes = br.ReadBytes((Int32)fs.Length);
     return bytes;
 }
开发者ID:syedusamamazhar,项目名称:LeatherAppRepo,代码行数:7,代码来源:formEmployee.aspx.cs

示例3: Read

        internal override void Read(BinaryReader reader)
        {
            Version = reader.ReadUInt16();
            VersionNeededToExtract = reader.ReadUInt16();
            Flags = (HeaderFlags) reader.ReadUInt16();
            CompressionMethod = (ZipCompressionMethod) reader.ReadUInt16();
            LastModifiedTime = reader.ReadUInt16();
            LastModifiedDate = reader.ReadUInt16();
            Crc = reader.ReadUInt32();
            CompressedSize = reader.ReadUInt32();
            UncompressedSize = reader.ReadUInt32();
            ushort nameLength = reader.ReadUInt16();
            ushort extraLength = reader.ReadUInt16();
            ushort commentLength = reader.ReadUInt16();
            DiskNumberStart = reader.ReadUInt16();
            InternalFileAttributes = reader.ReadUInt16();
            ExternalFileAttributes = reader.ReadUInt32();
            RelativeOffsetOfEntryHeader = reader.ReadUInt32();

            byte[] name = reader.ReadBytes(nameLength);
            Name = DecodeString(name);
            byte[] extra = reader.ReadBytes(extraLength);
            byte[] comment = reader.ReadBytes(commentLength);
            Comment = DecodeString(comment);
            LoadExtra(extra);
        }
开发者ID:kuzn-ilya,项目名称:sharpcompress,代码行数:26,代码来源:DirectoryEntryHeader.cs

示例4: ReadTEX

        private void ReadTEX(string filename, Stream tex)
        {
            var bin = new BinaryReader(tex);
            BlizzHeader chunk;
            long position = 0;
            while (position < tex.Length)
            {
                tex.Position = position;

                chunk = new BlizzHeader(bin.ReadChars(4), bin.ReadUInt32());
                chunk.Flip();

                position = tex.Position + chunk.Size;

                switch (chunk.ToString())
                {
                    case "TXVR": ReadTXVRChunk(bin);
                        continue;
                    case "TXFN": ReadTXFNChunk(bin, chunk);
                        continue;
                    case "TXBT":
                    case "TXMD": continue;
                    default:
                        throw new Exception(String.Format("{2} Found unknown header at offset {1} \"{0}\" while we should've already read them all!", chunk.ToString(), position.ToString(), filename));
                }
            }
        }
开发者ID:Ser0ja,项目名称:WoWFormatTest,代码行数:27,代码来源:TEXReader.cs

示例5: MDBlob

        public MDBlob(BinaryReader reader)
        {
            //read length indicator
            _length = MModule.DecodeInt32(reader);

            _data = reader.ReadBytes(_length);
        }
开发者ID:jkobtr,项目名称:CodePerspective,代码行数:7,代码来源:MDStringHeap.cs

示例6: BFCodeLabel

 internal BFCodeLabel(BinaryReader reader)
 {
     _name = reader.ReadCString(24);
     _offset = reader.ReadUInt32();
     int unused = reader.ReadInt32();
     _opcodeIndex = (int)_offset;
 }
开发者ID:TGEnigma,项目名称:Amicitia,代码行数:7,代码来源:BFCodeLabel.cs

示例7: RadarColorData

        static RadarColorData()
        {
            using (FileStream index = new FileStream(FileManager.GetFilePath("Radarcol.mul"), FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                BinaryReader bin = new BinaryReader(index);

                // Prior to 7.0.7.1, all clients have 0x10000 colors. Newer clients have fewer colors.
                int colorCount = (int)index.Length / 2;

                for (int i = 0; i < colorCount; i++)
                {
                    uint c = bin.ReadUInt16();
                    Colors[i] = 0xFF000000 | (
                            ((((c >> 10) & 0x1F) * multiplier)) |
                            ((((c >> 5) & 0x1F) * multiplier) << 8) |
                            (((c & 0x1F) * multiplier) << 16)
                            );
                }
                // fill the remainder of the color table with non-transparent magenta.
                for (int i = colorCount; i < Colors.Length; i++)
                {
                    Colors[i] = 0xFFFF00FF;
                }

                Metrics.ReportDataRead((int)bin.BaseStream.Position);
            }
        }
开发者ID:msx752,项目名称:UltimaXNA,代码行数:27,代码来源:RadarColorData.cs

示例8: ServerConnection

 public ServerConnection(TcpClient client, SslStream stream, BinaryReader binaryReader, BinaryWriter binaryWriter)
 {
     _client = client;
     _stream = stream;
     _binaryReader = binaryReader;
     _binaryWriter = binaryWriter;
 }
开发者ID:OrcusTechnologies,项目名称:Orcus.Plugins.ServerStressTest,代码行数:7,代码来源:ServerConnection.cs

示例9: Load

 public void Load(BinaryReader br, FileStream fs)
 {
     Offset = br.ReadInt32();
     Offset += 16;
     FrameCount = br.ReadInt32();
     MipWidth = br.ReadInt32();
     MipHeight = br.ReadInt32();
     StartX = br.ReadInt32();
     StartY = br.ReadInt32();
     TileCount = br.ReadUInt16();
     TotalCount = br.ReadUInt16();
     CellWidth = br.ReadUInt16();
     CellHeight = br.ReadUInt16();
     Frames = new EanFrame[TotalCount];
     long curPos = fs.Position;
     fs.Seek((long)Offset, SeekOrigin.Begin);
     for (int i = 0; i < TotalCount; i++)
     {
         Frames[i].X = br.ReadUInt16();
         Frames[i].Y = br.ReadUInt16();
         Frames[i].Width = br.ReadUInt16();
         Frames[i].Height = br.ReadUInt16();
     }
     fs.Seek((long)curPos, SeekOrigin.Begin);
 }
开发者ID:linxiubao,项目名称:UniShader,代码行数:25,代码来源:UVAnimation.cs

示例10: Deserialize

            public static MessageBase Deserialize(byte[] data)
            {
                using (MemoryStream stream = new MemoryStream(data))
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    // Ignore initial key
                    reader.ReadByte();
                    byte payloadLength = reader.ReadByte();
                    byte packageSequence = reader.ReadByte();
                    byte systemId = reader.ReadByte();
                    byte componentId = reader.ReadByte();
                    byte messageId = reader.ReadByte();

                    // Create instance based on message id
                    MessageBase message = null;
                    Type messageType;
                    if (_messageTypes.TryGetValue(messageId, out messageType))
                    {
                        message = (MessageBase)Activator.CreateInstance(messageType);

                        message._fields = new object[message._fieldTypes.Length];
                        for (int i = 0; i < message._fieldTypes.Length; ++i)
                        {
                            message.ReadField(reader, i);
                        }

                        // TODO: Verify CRC
                        byte LSBCRC = reader.ReadByte();
                        byte MSBCRC = reader.ReadByte();
                    }

                    return message;
                }
            }
开发者ID:Romout,项目名称:MavLinkGenerator,代码行数:34,代码来源:CSharpTemplate.cs

示例11: TightUnmarshal

    // 
    // Un-marshal an object instance from the data input stream
    // 
    public override void TightUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn, BooleanStream bs) 
    {
        base.TightUnmarshal(wireFormat, o, dataIn, bs);

        ConsumerInfo info = (ConsumerInfo)o;
        info.ConsumerId = (ConsumerId) TightUnmarshalCachedObject(wireFormat, dataIn, bs);
        info.Browser = bs.ReadBoolean();
        info.Destination = (ActiveMQDestination) TightUnmarshalCachedObject(wireFormat, dataIn, bs);
        info.PrefetchSize = dataIn.ReadInt32();
        info.MaximumPendingMessageLimit = dataIn.ReadInt32();
        info.DispatchAsync = bs.ReadBoolean();
        info.Selector = TightUnmarshalString(dataIn, bs);
        info.SubscriptionName = TightUnmarshalString(dataIn, bs);
        info.NoLocal = bs.ReadBoolean();
        info.Exclusive = bs.ReadBoolean();
        info.Retroactive = bs.ReadBoolean();
        info.Priority = dataIn.ReadByte();

        if (bs.ReadBoolean()) {
            short size = dataIn.ReadInt16();
            BrokerId[] value = new BrokerId[size];
            for( int i=0; i < size; i++ ) {
                value[i] = (BrokerId) TightUnmarshalNestedObject(wireFormat,dataIn, bs);
            }
            info.BrokerPath = value;
        }
        else {
            info.BrokerPath = null;
        }
        info.AdditionalPredicate = (BooleanExpression) TightUnmarshalNestedObject(wireFormat, dataIn, bs);
        info.NetworkSubscription = bs.ReadBoolean();
        info.OptimizedAcknowledge = bs.ReadBoolean();
        info.NoRangeAcks = bs.ReadBoolean();

    }
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:38,代码来源:ConsumerInfoMarshaller.cs

示例12: DeCrypting

 private static string DeCrypting()
 {
     var res = string.Empty;
     var file = new FileStream(Controller.GetPath(), FileMode.Open, FileAccess.Read, FileShare.None, 32, FileOptions.SequentialScan);
     var reader = new BinaryReader(file);
     var writer = new BinaryWriter(new FileStream(Processor.GetNewName(Controller.GetPath()), FileMode.Create, FileAccess.Write,
         FileShare.None, 32, FileOptions.WriteThrough));
     try
     {
         var pos = 0;
         while (pos < file.Length)
         {
             var c = reader.ReadUInt16();
             //var pow = Processor.fast_exp(c, Controller.GetKc(), Controller.GetR());
             var pow = Processor.Pows(c, Controller.GetKc(), Controller.GetR());
             if (pos < 256) res += pow + " ";
             writer.Write((byte)(pow));
             pos += 2;
         }
     }
     finally
     {
         writer.Close();
         reader.Close();
     }
     return "Decoding Complete!\n" + res;
 }
开发者ID:Emaxan,项目名称:TI_Laba4_RSA,代码行数:27,代码来源:Decoding.cs

示例13: RespawnInfo

        public RespawnInfo(BinaryReader reader, int Version, int Customversion)
        {
            MonsterIndex = reader.ReadInt32();

            Location = new Point(reader.ReadInt32(), reader.ReadInt32());

            Count = reader.ReadUInt16();
            Spread = reader.ReadUInt16();

            Delay = reader.ReadUInt16();
            Direction = reader.ReadByte();

            if (Envir.LoadVersion >= 36)
            {
                RoutePath = reader.ReadString();
            }

            if (Version > 67)
            {
                RandomDelay = reader.ReadUInt16();
                RespawnIndex = reader.ReadInt32();
                SaveRespawnTime = reader.ReadBoolean();
                RespawnTicks = reader.ReadUInt16();
            }
            else
            {
                RespawnIndex = ++SMain.Envir.RespawnIndex;
            }
        }
开发者ID:Pete107,项目名称:Mir2,代码行数:29,代码来源:RespawnInfo.cs

示例14: TestIncompleteRewind

 public void TestIncompleteRewind()
 {
     MemoryStream ms = new MemoryStream();
     BinaryWriter bw = new BinaryWriter(ms);
     bw.Write(1);
     bw.Write(2);
     bw.Write(3);
     bw.Write(4);
     bw.Write(5);
     bw.Write(6);
     bw.Write(7);
     bw.Flush();
     ms.Position = 0;
     RewindableStream stream = new RewindableStream(ms);
     stream.StartRecording();
     BinaryReader br = new BinaryReader(stream);
     Assert.AreEqual(br.ReadInt32(), 1);
     Assert.AreEqual(br.ReadInt32(), 2);
     Assert.AreEqual(br.ReadInt32(), 3);
     Assert.AreEqual(br.ReadInt32(), 4);
     stream.Rewind(true);
     Assert.AreEqual(br.ReadInt32(), 1);
     Assert.AreEqual(br.ReadInt32(), 2);
     stream.StartRecording();
     Assert.AreEqual(br.ReadInt32(), 3);
     Assert.AreEqual(br.ReadInt32(), 4);
     Assert.AreEqual(br.ReadInt32(), 5);
     stream.Rewind(true);
     Assert.AreEqual(br.ReadInt32(), 3);
     Assert.AreEqual(br.ReadInt32(), 4);
     Assert.AreEqual(br.ReadInt32(), 5);
     Assert.AreEqual(br.ReadInt32(), 6);
     Assert.AreEqual(br.ReadInt32(), 7);
 }
开发者ID:yaozd,项目名称:sharpcompress,代码行数:34,代码来源:RewindableStreamTest.cs

示例15: KinectReader

 public KinectReader(Stream fileStream, int width, int height)
 {
     this.Width = width;
     this.Height = height;
     this.reader = new BinaryReader(fileStream);
     this.createIndexes();
 }
开发者ID:nerndt,项目名称:iRobotKinect,代码行数:7,代码来源:KinectReader.cs


注:本文中的System.IO.BinaryReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。