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


C# Stream.Read1方法代码示例

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


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

示例1: Read

        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            while (bytesLeft > 0)
            {
                stream.Read1(ref bytesLeft);
            }
            Value = true;
        }
开发者ID:Rashed-Hoque,项目名称:IdSharp,代码行数:12,代码来源:Podcast.cs

示例2: Read

        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            long playCount = 0;
            while (bytesLeft > 0)
            {
                playCount <<= 8;
                playCount += stream.Read1(ref bytesLeft);
            }

            Value = playCount;
        }
开发者ID:Rashed-Hoque,项目名称:IdSharp,代码行数:15,代码来源:PlayCount.cs

示例3: ReadString

        public static string ReadString(EncodingType textEncoding, Stream stream)
        {
            if (stream == null)
                throw new ArgumentNullException("stream");

            string returnValue;
            List<byte> byteList = new List<byte>();

            if (textEncoding == EncodingType.ISO88591)
            {
                byte readByte = stream.Read1();
                while (readByte != 0)
                {
                    byteList.Add(readByte);

                    readByte = stream.Read1();
                }

                returnValue = ByteUtils.ISO88591GetString(byteList.ToArray());
            }
            else if (textEncoding == EncodingType.Unicode)
            {
                byte byte1;
                byte byte2;
                do
                {
                    byte1 = stream.Read1();
                    byteList.Add(byte1);

                    byte2 = stream.Read1();
                    byteList.Add(byte2);
                } while (byte1 != 0 || byte2 != 0);

                byte[] byteArray = byteList.ToArray();
                if (byteArray.Length >= 2)
                {
                    // If BOM is part of the string, decode as the appropriate Unicode type.
                    // If no BOM is present use Little Endian Unicode.
                    if (byteArray[0] == 0xFF && byteArray[1] == 0xFE)
                        returnValue = Encoding.Unicode.GetString(byteArray, 2, byteArray.Length - 2);
                    else if (byteArray[0] == 0xFE && byteArray[1] == 0xFF)
                        returnValue = Encoding.BigEndianUnicode.GetString(byteArray, 2, byteArray.Length - 2);
                    else
                        returnValue = Encoding.Unicode.GetString(byteArray, 0, byteArray.Length);
                }
                else
                {
                    returnValue = Encoding.Unicode.GetString(byteArray, 0, byteArray.Length);
                }
            }
            else if (textEncoding == EncodingType.UTF16BE)
            {
                byte byte1;
                byte byte2;
                do
                {
                    byte1 = stream.Read1();
                    byteList.Add(byte1);

                    byte2 = stream.Read1();
                    byteList.Add(byte2);
                } while (byte1 != 0 || byte2 != 0);

                byte[] byteArray = byteList.ToArray();
                if (byteArray.Length >= 2)
                {
                    // If BOM is part of the string, remove before decoding.
                    if (byteArray[0] == 0xFE && byteArray[1] == 0xFF)
                        returnValue = Encoding.BigEndianUnicode.GetString(byteArray, 2, byteArray.Length - 2);
                    else
                        returnValue = Encoding.BigEndianUnicode.GetString(byteArray, 0, byteArray.Length);
                }
                else
                {
                    returnValue = Encoding.BigEndianUnicode.GetString(byteArray, 0, byteArray.Length);
                }
            }
            else if (textEncoding == EncodingType.UTF8)
            {
                byte readByte = stream.Read1();
                while (readByte != 0)
                {
                    byteList.Add(readByte);

                    readByte = stream.Read1();
                }

                returnValue = Encoding.UTF8.GetString(byteList.ToArray());
            }
            else
            {
                // Most likely bad data
                string msg = string.Format("Text Encoding '{0}' unknown at position {1}", textEncoding, stream.Position);
                Trace.WriteLine(msg);
                return "";
            }

            returnValue = returnValue.TrimEnd('\0');
            return returnValue;
        }
开发者ID:Rashed-Hoque,项目名称:IdSharp,代码行数:100,代码来源:ID3v2Utils.cs

示例4: Read

        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);
            if (_frameHeader.FrameSizeExcludingAdditions >= 4)
            {
                TextEncoding = (EncodingType)stream.Read1();
                LanguageCode = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, 3);

                int tmpBytesLeft = _frameHeader.FrameSizeExcludingAdditions - 1 /*encoding*/- 3 /*language code*/;
                ContentDescriptor = ID3v2Utils.ReadString(TextEncoding, stream, ref tmpBytesLeft);

                Text = ID3v2Utils.ReadString(_textEncoding, stream, tmpBytesLeft);
            }
            else
            {
                string msg = string.Format("Under-sized ({0} bytes) unsynchronized text frame at position {1}", _frameHeader.FrameSizeExcludingAdditions, stream.Position);
                Trace.WriteLine(msg);

                LanguageCode = "eng";
                ContentDescriptor = "";
                Text = "";
            }
        }
开发者ID:Rashed-Hoque,项目名称:IdSharp,代码行数:23,代码来源:UnsynchronizedText.cs

示例5: Read

        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            Items.Clear();

            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft >= 1)
            {
                TextEncoding = (EncodingType)stream.Read1(ref bytesLeft);
                if (bytesLeft >= 3)
                {
                    LanguageCode = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, 3);
                    bytesLeft -= 3;
                    if (bytesLeft >= 2)
                    {
                        TimestampFormat = (TimestampFormat)stream.Read1(ref bytesLeft);
                        ContentType = (TextContentType)stream.Read1(ref bytesLeft);
                        if (bytesLeft > 0)
                        {
                            ContentDescriptor = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);

                            while (bytesLeft > 0)
                            {
                                string lyrics = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                                if (bytesLeft >= 4)
                                {
                                    SynchronizedTextItem textItem = new SynchronizedTextItem();
                                    textItem.Text = lyrics;
                                    textItem.Timestamp = stream.ReadInt32();
                                    bytesLeft -= 4;
                                    Items.Add(textItem);
                                }
                            }
                        }
                        else
                        {
                            // Incomplete frame
                            ContentDescriptor = "";
                        }
                    }
                    else
                    {
                        // Incomplete frame
                        TimestampFormat = TimestampFormat.Milliseconds;
                        ContentType = TextContentType.Other;
                        ContentDescriptor = "";
                    }
                }
                else
                {
                    // Incomplete frame
                    LanguageCode = "eng";
                    TimestampFormat = TimestampFormat.Milliseconds;
                    ContentType = TextContentType.Other;
                    ContentDescriptor = "";
                }
            }
            else
            {
                // Incomplete frame
                TextEncoding = EncodingType.ISO88591;
                LanguageCode = "eng";
                TimestampFormat = TimestampFormat.Milliseconds;
                ContentType = TextContentType.Other;
                ContentDescriptor = "";
            }

            if (bytesLeft > 0)
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }
开发者ID:Rashed-Hoque,项目名称:IdSharp,代码行数:74,代码来源:SynchronizedText.cs

示例6: Read

        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);
            if (_frameHeader.FrameSizeExcludingAdditions > 0)
            {
                TextEncoding = (EncodingType)stream.Read1();
                int bytesLeft = _frameHeader.FrameSizeExcludingAdditions - 1;
                Description = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                Value = ID3v2Utils.ReadString(TextEncoding, stream, bytesLeft);
            }
            else
            {
                /*String msg = String.Format("0 length frame '{0}' at position {1}", "TXXX", stream.Position);
                Trace.WriteLine(msg);*/

                Description = string.Empty;
                Value = string.Empty;
            }
        }
开发者ID:Rashed-Hoque,项目名称:IdSharp,代码行数:19,代码来源:TXXXFrame.cs

示例7: Read

        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);
            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft > 0)
            {
                TextEncoding = (EncodingType)stream.Read1(ref bytesLeft);
                if (bytesLeft > 0)
                {
                    MimeType = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                    if (bytesLeft > 1)
                    {
                        byte flags = stream.Read1(ref bytesLeft);
                        _isMpegOrAac = ((flags & 0x01) == 0x00);
                        EquivalentText = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                        if (bytesLeft > 0)
                        {
                            _audioData = stream.Read(bytesLeft);
                            bytesLeft = 0;
                        }
                    }
                    else
                    {
                        EquivalentText = null;
                        _audioData = null;
                    }
                }
                else
                {
                    MimeType = null;
                    EquivalentText = null;
                    _audioData = null;
                }
            }
            else
            {
                TextEncoding = EncodingType.ISO88591;
                MimeType = null;
                EquivalentText = null;
                _audioData = null;
            }

            if (bytesLeft > 0)
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }
开发者ID:kiliman,项目名称:IdSharp,代码行数:48,代码来源:AudioText.cs

示例8: Read

        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            Reset();

            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft > 0)
            {
                OwnerIdentifier = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                if (bytesLeft > 0)
                {
                    MethodSymbol = stream.Read1(ref bytesLeft);
                    if (bytesLeft > 0)
                    {
                        EncryptionData = stream.Read(bytesLeft);
                        bytesLeft = 0;
                    }
                }
            }

            if (bytesLeft != 0)
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }
开发者ID:kiliman,项目名称:IdSharp,代码行数:27,代码来源:EncryptionMethod.cs

示例9: Read

        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            // Some taggers write 0 byte sized frames (which is explicitly forbidden by the spec)
            if (_frameHeader.FrameSizeExcludingAdditions >= 1)
            {
                TextEncoding = (EncodingType)stream.Read1();
                Value = ID3v2Utils.ReadString(_textEncoding, stream, _frameHeader.FrameSizeExcludingAdditions - 1);
            }
            else
            {
                //String msg = String.Format("Under-sized ({0} bytes) text frame at position {1}", m_FrameHeader.FrameSizeExcludingAdditions, stream.Position);
                //Trace.WriteLine(msg);

                TextEncoding = EncodingType.ISO88591;
                Value = "";
            }
        }
开发者ID:kiliman,项目名称:IdSharp,代码行数:19,代码来源:TextFrame.cs

示例10: Read

        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            // RVAD/RVA2
            /*Double original = -65534;
            Double newVal = Math.Log10(1 + original/65535.0)*20.0*512.0;
            Double original2 = Math.Pow(10, newVal/(20.0*512.0));
            original2 = original2 - 1;
            original2 *= 65535.0;*/

            /*Double original = 10000;
            Double newVal = Math.Log10(1 + original / 65535.0);
            Double original2 = Math.Pow(10, newVal);
            original2 = original2 - 1;
            original2 *= 65535.0;*/

            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;
            if (bytesLeft > 0)
            {
                // todo: there needs to be some kind of a test to see if this is RVAD/RVA2 format, too
                // much varying implementation in 2.3 and 2.4

                bool isRVA2 = (_frameHeader.TagVersion == ID3v2TagVersion.ID3v24);

                if (isRVA2)
                {
                    // sometimes "identification" is completely ommitted... grr
                    Identification = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                    while (bytesLeft >= 3)
                    {
                        // TODO: Implementation not complete
                        byte channelType = stream.Read1(ref bytesLeft);
                        //if (channelType == 16) break; // Invalid, probably stored as an ID3v2.3 RVAD frame
                        // TODO: some kind of switch.. maybe a new internal enum
                        short volumeAdjustment = stream.ReadInt16(ref bytesLeft);
                        if (bytesLeft > 0)
                        {
                            // sometimes represented as BITS representing peak.. seriously.
                            byte bytesRepresentingPeak = stream.Read1(ref bytesLeft);
                            if (bytesRepresentingPeak == 0) break;
                            if (bytesLeft >= bytesRepresentingPeak)
                            {
                                // TODO: Finish implementation
                                byte[] peakVolume = stream.Read(bytesRepresentingPeak);
                                bytesLeft -= peakVolume.Length;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    if (bytesLeft > 0)
                    {
                        //Trace.WriteLine("Invalid RVA2 frame");
                        //stream.Seek(bytesLeft, SeekOrigin.Current);
                        //bytesLeft = 0;
                        // Try to read it like an ID3v2.3 RVAD frame
                        stream.Seek(bytesLeft - _frameHeader.FrameSizeExcludingAdditions, SeekOrigin.Current);
                        bytesLeft = _frameHeader.FrameSizeExcludingAdditions;
                        isRVA2 = false;
                    }
                    else
                    {
                        // TODO
                        //MessageBox.Show("valid RVA2 frame, omg!");
                    }
                }

                // ID3v2.2, ID3v2.3, or mal-formed ID3v2.4
                if (isRVA2 == false)
                {
                    byte incrementDecrement = stream.Read1(ref bytesLeft);
                    if (bytesLeft > 0)
                    {
                        byte bitsUsedForVolumeDescription = stream.Read1(ref bytesLeft);
                        int bytesUsedForVolumeDescription = bitsUsedForVolumeDescription / 8;

                        // TODO: (may be useful for testing which implementation)
                        // if bits used for volume description is > 64, don't bother

                        // Relative volume change, right
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            FrontRightAdjustment = ByteUtils.ConvertToInt64(byteArray) * (ByteUtils.IsBitSet(incrementDecrement, 0) ? 1 : -1);
                        }
                        // Relative volume change, left
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            FrontLeftAdjustment = ByteUtils.ConvertToInt64(byteArray) * (ByteUtils.IsBitSet(incrementDecrement, 1) ? 1 : -1);
                        }
                        // Peak volume right
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            FrontRightPeak = ByteUtils.ConvertToInt64(byteArray);
//.........这里部分代码省略.........
开发者ID:Rashed-Hoque,项目名称:IdSharp,代码行数:101,代码来源:RelativeVolumeAdjustment.cs

示例11: Read

        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;
            if (bytesLeft > 0)
            {
                UserEmail = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                if (bytesLeft > 0)
                {
                    Rating = stream.Read1(ref bytesLeft);
                    if (bytesLeft > 0)
                    {
                        byte[] playCount = stream.Read(bytesLeft);
                        PlayCount = ByteUtils.ConvertToInt64(playCount);
                    }
                    else
                    {
                        PlayCount = 0;
                    }
                }
                else
                {
                    Rating = 0;
                    PlayCount = 0;
                }
            }
            else
            {
                UserEmail = null;
                Rating = 0;
                PlayCount = 0;
            }
        }
开发者ID:kiliman,项目名称:IdSharp,代码行数:34,代码来源:Popularimeter.cs

示例12: Read

        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            Reset();

            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;
            if (bytesLeft > 1)
            {
                TextEncoding = (EncodingType)stream.Read1(ref bytesLeft);
                string priceString = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);

                if (!string.IsNullOrEmpty(priceString))
                {
                    foreach (string priceItem in priceString.Split('/'))
                    {
                        if (priceItem.Length > 3)
                        {
                            decimal price;
                            string pricePart = priceItem.Substring(3, priceItem.Length - 3);
                            if (decimal.TryParse(pricePart, System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo, out price))
                            {
                                IPriceInformation priceInfo = new PriceInformation();
                                priceInfo.CurrencyCode = priceItem.Substring(0, 3);
                                priceInfo.Price = price;
                                _priceList.Add(priceInfo);
                            }
                        }
                    }
                }

                if (bytesLeft > 0)
                {
                    string validUntil = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, 8);
                    bytesLeft -= 8;

                    if (validUntil.Length == 8)
                    {
                        validUntil = string.Format("{0}-{1}-{2}", validUntil.Substring(0, 4),
                            validUntil.Substring(4, 2), validUntil.Substring(6, 2));
                        DateTime.TryParse(validUntil, out _validUntil);
                    }

                    if (bytesLeft > 0)
                    {
                        ContactUrl = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);

                        if (bytesLeft > 0)
                        {
                            ReceivedAs = (ReceivedAs)stream.Read1(ref bytesLeft);
                            NameOfSeller = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                            Description = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                            SellerLogoMimeType = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                            if (bytesLeft > 0)
                            {
                                SellerLogo = stream.Read(bytesLeft);
                                bytesLeft = 0;
                            }
                        }
                    }
                }
            }

            if (bytesLeft != 0)
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }
开发者ID:kiliman,项目名称:IdSharp,代码行数:68,代码来源:Commercial.cs

示例13: Read

        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            // Sometimes a frame size of "0" comes through (which is explicitly forbidden in spec)
            if (_frameHeader.FrameSizeExcludingAdditions >= 1)
            {
                TextEncoding = (EncodingType)stream.Read1();

                // TODO: A common mis-implementation is to exclude the language code and description
                // Haven't decided how to handle this yet.  Maybe if a lookup to the language table fails,
                // the rest of the frame should be treated as suspicious.

                if (_frameHeader.FrameSizeExcludingAdditions >= 4)
                {
                    string languageCode = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, 3);
                    int bytesLeft = _frameHeader.FrameSizeExcludingAdditions - 1 - 3;
                    string description = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);

                    bool invalidFrame = false;
                    if (LanguageHelper.Languages.ContainsKey(languageCode.ToLower()) == false && languageCode.ToLower() != "xxx")
                    {
                        // most likely, it's en\0, or some other funk
                        if (languageCode.StartsWith("en"))
                        {
                            languageCode = "";
                        }

                        invalidFrame = true;

                        if (bytesLeft == 0)
                        {
                            Description = "";
                        }
                        else
                        {
                            Description = languageCode + description;
                        }
                        LanguageCode = "eng";
                    }
                    else
                    {
                        LanguageCode = languageCode;
                        Description = description;
                    }

                    if (bytesLeft > 0)
                    {
                        Value = ID3v2Utils.ReadString(TextEncoding, stream, bytesLeft);
                    }
                    else
                    {
                        if (invalidFrame)
                        {
                            if (languageCode.Contains("\0"))
                            {
                                // forget it, too messed up.
                                Value = "";
                            }
                            else
                            {
                                Value = languageCode + description;
                            }
                        }
                        else
                        {
                            Value = "";
                        }
                    }
                }
                else
                {
                    string msg = string.Format("Under-sized ({0} bytes) COMM frame at position {1}", _frameHeader.FrameSizeExcludingAdditions, stream.Position);
                    Trace.WriteLine(msg);

                    LanguageCode = "eng";
                    Value = "";
                }
            }
            else
            {
                string msg = string.Format("Under-sized ({0} bytes) COMM frame at position {1}", _frameHeader.FrameSizeExcludingAdditions, stream.Position);
                Trace.WriteLine(msg);

                LanguageCode = "eng";
                Value = "";
            }
        }
开发者ID:JayDZimmerman,项目名称:IdSharp,代码行数:88,代码来源:Comments.cs

示例14: Read

        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;
            if (bytesLeft >= 4)
            {
                TextEncoding = (EncodingType)stream.Read1(ref bytesLeft);
                MimeType = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                if (bytesLeft > 0)
                {
                    FileName = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                    if (bytesLeft > 0)
                    {
                        Description = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                        if (bytesLeft > 0)
                        {
                            EncapsulatedObject = stream.Read(bytesLeft);
                            bytesLeft = 0;
                        }
                    }
                }
            }

            // Seek to end of frame
            if (bytesLeft > 0)
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }
开发者ID:Rashed-Hoque,项目名称:IdSharp,代码行数:30,代码来源:GeneralEncapsulatedObject.cs

示例15: ReadUnsynchronized

        public static byte[] ReadUnsynchronized(Stream stream, int size)
        {
            using (MemoryStream byteList = new MemoryStream(size))
            {
                for (int i = 0; i < size; i++)
                {
                    byte myByte = stream.Read1();
                    byteList.WriteByte(myByte);
                    if (myByte == 0xFF)
                    {
                        myByte = stream.Read1(); // skip 0x00
                        if (myByte != 0)
                        {
                            byteList.WriteByte(myByte);
                            i++;
                        }
                    }
                }

                return byteList.ToArray();
            }
        }
开发者ID:Rashed-Hoque,项目名称:IdSharp,代码行数:22,代码来源:ID3v2Utils.cs


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