首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

在分析完成事前就遇到流结尾

2013-06-25 
在分析完成之前就遇到流结尾?public static object ByteToObject(byte[] bytes){System.IO.MemoryStream s

在分析完成之前就遇到流结尾?
public static object ByteToObject(byte[] bytes)
  {
  System.IO.MemoryStream stream = new System.IO.MemoryStream(bytes);
  System.Runtime.Serialization.IFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
  Object reobj = bf.Deserialize(stream);
  stream.Close();
  return reobj;
  }

在分析完成之前就遇到流结尾。


怎么回事

[解决办法]
把这句加在Deserialize那句之前试试:

stream.Position = 0;
[解决办法]

引用:
这是在数据库读取二进制数据, 然后就‘在分析完成之前就遇到流结尾’遇到这个问题。


????System.Runtime.Serialization.IFormatter 你数据库里存的难道是类?
[解决办法]
 Response.ContentEncoding = System.Text.Encoding.Default;
        Response.ContentType = "rar";
        Response.AddHeader("Content-Disposition", "attachment; filename=" 1.rar");
        Response.BinaryWrite(bytes);   

热点排行