コード例 #1
0
ファイル: StreamExtension.cs プロジェクト: uiopsczc/Test
        /// <summary>
        ///   在Stream读取len长度的数据
        /// </summary>
        /// <param name="self"></param>
        /// <param name="len"></param>
        /// <returns></returns>
        public static byte[] ReadBytes(this Stream self, int len)
        {
            var buf = new byte[len];

            len = self.ReadBytes(buf);
            if (len < buf.Length)
            {
                return(ByteUtil.SubBytes(buf, 0, len));
            }
            return(buf);
        }
コード例 #2
0
ファイル: StdioUtil.cs プロジェクト: uiopsczc/Test
        /// <summary>
        /// 在Stream读取len长度的数据
        /// </summary>
        /// <param name="inStream"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public static byte[] ReadStream(Stream inStream, int length)
        {
            var buffer = new byte[length];

            length = ReadStream(inStream, buffer);
            if (length < buffer.Length)
            {
                return(ByteUtil.SubBytes(buffer, 0, length));
            }
            return(buffer);
        }