c# byte转stream 和 stream 转 bye
Stream 和 byte[] 之间的转换
/* - - - - - - - - - - - - - - - - - - - - - - - -
* Stream 和 byte[] 之间的转换
* - - - - - - - - - - - - - - - - - - - - - - - */
/// <summary>
/// 将 Stream 转成 byte[]
/// </summary>
public byte[] StreamToBytes(Stream stream)
{
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);// 设置当前流的位置为流的开始
stream.Seek(0, SeekOrigin.Begin);
return bytes;
}
/// <summary>
/// 将 byte[] 转成 Stream
/// </summary>
public Stream BytesToStream(byte[] bytes)
{
Stream stream = new MemoryStream(bytes);
return stream;
}
相关文章
文章评论
热门评论
暂无评论


今天打开百度空间,就出现如下公告:由于九班空间于8月31日正式下线,旧版相关页面无法访问,为了继续使用空...
前段时间在51aspx上传了一份c#的源码,打算把它开源,然后等了大概三天左右,看到还是审核状态,我就有点奇怪了,...
会生活家庭记账本软件基本上每个界面都有导出到excel的按钮,下面以 账单管理 界面为例:1.我们进到 账单管理...
SELECT t.NAME AS 你的表名, p.rows AS RowCounts, SUM(a.total_pages) * 8 AS TotalSpaceKB, S...
