1  /// <summary>
 2         /// 二进制数组转流
 3         /// </summary>
 4         /// <param name="bytes"></param>
 5         /// <returns></returns>
 6         public static Stream BytesToStream(byte[] bytes)
 7         {
 8             Stream stream = new MemoryStream(bytes);
 9             return stream;
10         }
11 
12         /// <summary>
13         /// 流转二进制数组
14         /// </summary>
15         /// <param name="theStream"></param>
16         /// <returns></returns>
17         public static byte[] StreamToBytes(Stream theStream)
18         {
19             int index;
20             MemoryStream tempStream = new MemoryStream();
21             while ((index = theStream.ReadByte()) != -1)
22             {
23                 tempStream.WriteByte(((byte)index));
24             }
25             return tempStream.ToArray();
26         }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-22
猜你喜欢
  • 2021-07-19
  • 2022-12-23
  • 2021-10-22
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
相关资源
相似解决方案