.net stream 转成 bytes[] 的实例和注意事项
public static byte[] Stream2Bytes(ref Stream s)
{
if (s == null)
{
return null;
}
s.Seek(0, SeekOrigin.Begin);
byte[] bytes = new byte[s.Length];
s.Read(bytes, 0, bytes.Length);
s.Close();
return bytes;
}
注意在stream转换之前一定要先把stream 定位到 头

浙公网安备 33010602011771号