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


C# BinaryReader.ReadByte方法代码示例

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


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

示例1: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        string newFile = Server.MapPath("../") + "\\UploadFile\\" + Request.QueryString["FilePath"] + "";
        FileStream newDoc = new FileStream(newFile, FileMode.Create, FileAccess.Write);
        BinaryReader br = new BinaryReader(Request.InputStream);
        BinaryWriter bw = new BinaryWriter(newDoc);
        br.BaseStream.Seek(0, SeekOrigin.Begin);
        bw.BaseStream.Seek(0, SeekOrigin.End);
        int enterNo = 0;
        int streamHeadLen = 0;

        while (br.BaseStream.Position < br.BaseStream.Length)
        {
            streamHeadLen++;
            char c = (char)br.ReadByte();
            if (enterNo < enterCount)
            {
                if (c == '\n')
                {
                    enterNo++;
                }
            }
            else
            {
                break;
            }
        }

        br.BaseStream.Seek(0, SeekOrigin.Begin);
        string strTemp = System.Text.UTF8Encoding.Default.GetString(br.ReadBytes(streamHeadLen - 1));
        while (br.BaseStream.Position < br.BaseStream.Length - 38)
        {
            bw.Write(br.ReadByte());
        }
        br.Close();
        bw.Flush();
        bw.Close();

        string[] requestStrings = { "RecordID", "UserID" };
        for (int i = 0; i < requestStrings.Length; i++)
        {
            string str = "Content-Disposition: form-data; name=\"" + requestStrings[i] + "\"\r\n\r\n";
            int index = strTemp.IndexOf(str) + str.Length;
            if (index != str.Length - 1)
            {
                for (int j = index; j < strTemp.Length; j++)
                {
                    if (strTemp[j] != '\r')
                        this.requestValues[i] += strTemp[j];
                    else
                        break;
                }
            }
        }
    }
开发者ID:cnbin,项目名称:HLB,代码行数:55,代码来源:SaveDoc.aspx.cs

示例2: using

    /*public static Texture2D LoadTGA(string fileName)
    {
        using (var imageFile = File.OpenRead(fileName))
        {
            return LoadTGA(imageFile);
        }
    }*/
    public static Texture2D LoadTGA(Stream TGAStream)
    {
        using (BinaryReader r = new BinaryReader(TGAStream))
        {
            // Skip some header info we don't care about.
            // Even if we did care, we have to move the stream seek point to the beginning,
            // as the previous method in the workflow left it at the end.
            r.BaseStream.Seek(12, SeekOrigin.Begin);

            short width = r.ReadInt16();
            short height = r.ReadInt16();
            int bitDepth = r.ReadByte();

            // Skip a byte of header information we don't care about.
            r.BaseStream.Seek(1, SeekOrigin.Current);

            Texture2D tex = new Texture2D(width, height);
            Color32[] pulledColors = new Color32[width * height];
            int length = width * height;

            if (bitDepth == 32)
            {
                for (int row = 1; row <= height; row++)
                {
                    for (int col = 0; col < width; col++)
                    {
                        byte red = r.ReadByte();
                        byte green = r.ReadByte();
                        byte blue = r.ReadByte();
                        byte alpha = r.ReadByte();

        //					pulledColors [i] = new Color32(blue, green, red, alpha);
                        pulledColors [length - (row * width) + col] = new Color32(blue, green, red, alpha);
                    }
                }
            } else if (bitDepth == 24)
            {
                for (int row = 1; row <= height; row++)
                {
                    for (int col = 0; col < width; col++)
                    {
                        byte red = r.ReadByte();
                        byte green = r.ReadByte();
                        byte blue = r.ReadByte();

                        pulledColors [length - (row * width) + col] = new Color32(blue, green, red, 1);
                    }
                }
            } else
            {
                throw new Exception("TGA texture had non 32/24 bit depth.");
            }

            tex.SetPixels32(pulledColors);
            tex.Apply();
            return tex;

        }
    }
开发者ID:cmdr2,项目名称:unity-obj-loader,代码行数:66,代码来源:TGALoader.cs

示例3: Decode

    public static ActionPayload Decode(byte[] payload)
    {
        MemoryStream stream = new MemoryStream(payload);
        BinaryReader reader = new BinaryReader(stream);

        byte op = reader.ReadByte ();

        ActionPayload action = new ActionPayload();

        switch (op) {

            case ActionPayload.OP_MOVEMENT:

                action.op = op;
                action.time = reader.ReadSingle ();

                action.position = new Vector3();
                action.position.x = reader.ReadSingle ();
                action.position.y = reader.ReadSingle ();
                action.position.z = reader.ReadSingle ();

                action.rot = reader.ReadSingle ();
                action.state = (int)reader.ReadSingle ();

            break;
        }

        return action;
    }
开发者ID:hydna,项目名称:hydna-unity-chicken-demo,代码行数:29,代码来源:ActionPayload.cs

示例4: Load

	public override void Load(BinaryReader br) {
		base.Load(br);
		dir = br.ReadBoolean() ? 1 : -1;
		height = br.ReadByte();
		sin = br.ReadSingle();
		sinSpeed = br.ReadSingle();
	}
开发者ID:mugmickey,项目名称:Terraria-tConfig-Mods,代码行数:7,代码来源:EffectFireflyHover.cs

示例5: ReadObjectState

    public void ReadObjectState(BinaryReader binaryReader)
    {
        this.subString = binaryReader.ReadString();
        this.valueX = binaryReader.ReadInt32();
        this.valueB = binaryReader.ReadByte();

        this.gameObject.name = binaryReader.ReadString();
    }
开发者ID:niguerrac,项目名称:UnityUI,代码行数:8,代码来源:SimpleSubObject.cs

示例6: Test_Setup

    void Test_Setup()
    {
        using( FileStream fs = TmpFileStream() ) {
            BinaryReader reader = new BinaryReader( fs );

            foreach(ColoredPoint cp in mockCloud) {
                Assert_Equal( cp.v.x, reader.ReadSingle() );
                Assert_Equal( cp.v.y, reader.ReadSingle() );
                Assert_Equal( cp.v.z, reader.ReadSingle() );

                Assert_Approximately( cp.c.r, (float)reader.ReadByte()/255.0f, bytePrecision );
                Assert_Approximately( cp.c.g, (float)reader.ReadByte()/255.0f, bytePrecision );
                Assert_Approximately( cp.c.b, (float)reader.ReadByte()/255.0f, bytePrecision );
                fs.Seek(1,SeekOrigin.Current);
            }
        }
    }
开发者ID:artm,项目名称:ExplodedViews,代码行数:17,代码来源:CloudStream_Test.cs

示例7: Load

	public override void Load(BinaryReader br) {
		base.Load(br);
		type = br.ReadByte();
		color1 = NetworkHelper.ReadColor(br);
		color2 = NetworkHelper.ReadColor(br);
		rot1 = br.ReadSingle();
		rotSpeed1 = br.ReadSingle();
		rot2 = br.ReadSingle();
		rotSpeed2 = br.ReadSingle();
	}
开发者ID:mugmickey,项目名称:Terraria-tConfig-Mods,代码行数:10,代码来源:EffectFireflyFlame.cs

示例8: Class3

 public Class3(string path)
 {
     BinaryReader binaryReader = new BinaryReader(new StreamReader(path).BaseStream);
     List<byte> list = new List<byte>();
     byte item = binaryReader.ReadByte();
     while (true)
     {
         try
         {
             list.Add(item);
             item = binaryReader.ReadByte();
         }
         catch
         {
             break;
         }
     }
     this.byte_0 = list.ToArray();
     binaryReader.Close();
     Class2.smethod_0(ref this.byte_0);
     Debug.WriteLine(Encoding.Default.GetString(this.byte_0));
 }
开发者ID:ZelkovaHabbo,项目名称:NF3_Compilable,代码行数:22,代码来源:Class3.cs

示例9: Start

    // Use this for initialization
    void Start()
    {
        //save a list of numbers into file.dat
                byte[] a = new byte[] { 5, 5, 0, 0, 0, 0, 1,   0, 0, 1, 0, 1,   0, 1, 1, 1, 1,   0, 1, 1, 1, 1,   0, 0, 0, 1, 1,  1,0,1,1,1,  0,0,0,1,1};
                using (BinaryWriter b = new BinaryWriter(File.Open("terrain/file.dat", FileMode.Create))) {

                        foreach (byte i in a) {
                                b.Write (i);
                        }
                }
                //read the save file
                using (BinaryReader b = new BinaryReader(File.Open("terrain/file.dat", FileMode.Open))) {
                        //position in the stream
                        int pos = 2;
                        int length = (int)b.BaseStream.Length;	//length of the stream
                        //read the first two numbers
                        dataWidth = (int)b.ReadByte ();

                        dataHeight = (int)b.ReadByte ();
                        //initialize the data variable
                        data = new byte[dataWidth, dataHeight];
                        //iterate through array
                        for (int i=0; i<dataWidth; i++) {
                                for (int j=0; j<dataHeight; j++) {
                                    //read the next byte
                                    //write it into the array
                                    byte bit = (byte)b.ReadByte();
                                    data[i,j] = bit;
                                    //and for now, instantiate a block if bit is 1
                                    if(bit==1){
                                        Instantiate(groundBlock,transform.position + new Vector3((float)i * gridx,(float)j * -gridy,0.0f), Quaternion.identity);
                                    }

                                }
                        }

                }
    }
开发者ID:TheFatCat,项目名称:Castaway,代码行数:39,代码来源:TerrainLoader.cs

示例10: ReadProgress

	public void ReadProgress(BinaryReader br) {
		int type = (int)br.ReadByte();
		switch (type) {
			case 1: {
				progress = br.ReadDouble();
				double d = br.ReadDouble();
				if (progressMax == null) progressMax = d;
			} break;
			case 2: {
				progress = br.ReadInt32();
				int i = br.ReadInt32();
				if (progressMax == null) progressMax = i;
			} break;
			default: break;
		}
	}
开发者ID:mugmickey,项目名称:Terraria-tConfig-Mods,代码行数:16,代码来源:Achievement.cs

示例11: Read

    public static double[][] Read(string fileName, out int sampFreq)
    {
        using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
        {
            using (BinaryReader br = new BinaryReader(fs))
            {
                if (br.ReadInt32() != RiffHeader)
                {
                    throw new Exception("WAVファイルじゃない\(^o^)/");
                }
                br.ReadInt32();
                if (br.ReadInt32() != WaveHeader)
                {
                    throw new Exception("WAVファイルじゃない\(^o^)/");
                }

                while (br.ReadInt32() != FmtHeader)
                {
                    br.BaseStream.Seek(br.ReadInt32() + 1 >> 1 << 1, SeekOrigin.Current);
                }

                int numChannels;
                {
                    byte[] chunk = new byte[br.ReadInt32()];
                    br.Read(chunk, 0, chunk.Length);
                    ReadFmtChunk(chunk, out numChannels, out sampFreq);
                    if ((chunk.Length & 1) > 0) br.ReadByte();
                }

                while (br.ReadInt32() != DataHeader)
                {
                    br.BaseStream.Seek(br.ReadInt32() + 1 >> 1 << 1, SeekOrigin.Current);
                }

                {
                    byte[] chunk = new byte[br.ReadInt32()];
                    br.Read(chunk, 0, chunk.Length);
                    return ReadDataChunk(chunk, numChannels);
                }
            }
        }
    }
开发者ID:sinshu,项目名称:wav_utility,代码行数:42,代码来源:WavUtil.cs

示例12: decode

    public ItemQuote decode(Stream wire)
    {
        BinaryReader src = new BinaryReader(new BufferedStream(wire));

        long itemNumber = IPAddress.NetworkToHostOrder(src.ReadInt64());
        int quantity = IPAddress.NetworkToHostOrder(src.ReadInt32());
        int unitPrice = IPAddress.NetworkToHostOrder(src.ReadInt32());
        byte flags = src.ReadByte();

        int stringLength = src.Read(); // Returns an unsigned byte as an int
        if (stringLength == -1)
          throw new EndOfStreamException();
        byte[] stringBuf = new byte[stringLength];
        src.Read(stringBuf, 0, stringLength);
        String itemDesc = encoding.GetString(stringBuf);

        return new ItemQuote(itemNumber,itemDesc, quantity, unitPrice,
          ((flags & ItemQuoteBinConst.DISCOUNT_FLAG) == ItemQuoteBinConst.DISCOUNT_FLAG),
          ((flags & ItemQuoteBinConst.IN_STOCK_FLAG) == ItemQuoteBinConst.IN_STOCK_FLAG));
    }
开发者ID:jin55132,项目名称:TCPCSharp,代码行数:20,代码来源:ItemQuoteDecoderBin.cs

示例13: HasFullMessage

	private static bool HasFullMessage(Stream stream)
	{
		BinaryReader reader = new BinaryReader(stream);
		long oldPosition = stream.Position;
		bool result = true;

		if (stream.Length - stream.Position < 5)
			result = false;

		if (result)
		{
			reader.ReadByte();
			uint size = reader.ReadUInt32();
			if (stream.Length - stream.Position < size)
				result = false;
		}

		stream.Position = oldPosition;
		return result;
	}
开发者ID:dannybess,项目名称:0-Back-Project,代码行数:20,代码来源:DataReceiver.cs

示例14: Load

 public int Load(string path, Encoding encode)
 {
     try
     {
         FileStream fs = new FileStream(Application.persistentDataPath + "/" + path, FileMode.Open, FileAccess.Read);
         BinaryReader br = new BinaryReader(fs);
         var bin = new System.Collections.Generic.List<byte>();
         try
         {
             while (true) { bin.Add(br.ReadByte()); }
         }
         catch (EndOfStreamException) { }
         str = encode.GetString(aes.Decrypt(bin.ToArray()));
         br.Close();
     }
     catch {
         // ロード失敗
         return -1;
     }
     return 0;
 }
开发者ID:GotoK,项目名称:H401,代码行数:21,代码来源:FileLoader.cs

示例15: ServiceDescriptor

        /// <summary>
        /// Initializes a new instance of the <see cref="ServiceDescriptor" /> class.
        /// </summary>
        /// <param name="name">Name.</param>
        /// <param name="reader">Reader.</param>
        /// <param name="services">Services.</param>
        public ServiceDescriptor(string name, BinaryReader reader, IServices services)
        {
            Debug.Assert(reader != null);
            Debug.Assert(services != null);
            Debug.Assert(!string.IsNullOrEmpty(name));

            _services = services;
            Name = name;

            CacheName = reader.ReadString();
            MaxPerNodeCount = reader.ReadInt();
            TotalCount = reader.ReadInt();
            OriginNodeId = reader.ReadGuid() ?? Guid.Empty;
            AffinityKey = reader.ReadObject<object>();
            Platform = (Platform) reader.ReadByte();

            var mapSize = reader.ReadInt();
            var snap = new Dictionary<Guid, int>(mapSize);

            for (var i = 0; i < mapSize; i++)
                snap[reader.ReadGuid() ?? Guid.Empty] = reader.ReadInt();

            TopologySnapshot = snap.AsReadOnly();
        }
开发者ID:RazmikMkrtchyan,项目名称:ignite,代码行数:30,代码来源:ServiceDescriptor.cs


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