怎么把stream转成MemoryStream
public static Stream sss(Stream inStream)
{
//把instream转成MemoryStream
}
------解决方案--------------------不可能直接转的,需要从Stream把数据读出来,写入MemoryStream。
MemoryStream ms = new MemoryStream();
byte[] buffer = new byte[1024];
while(true) {
int sz = inStream.Read(buffer, 0, 1024);
if (sz == 0) break;
ms.Write(buffer, 0, sz);
}
ms.Position = 0;
return ms;