我想反序列化一个流,但我总是得到这个错误“分析完成之前遇到的流结束”?分析完成之前遇到的流结束?
下面是代码:
//Some code here
BinaryFormatter b = new BinaryFormatter();
return (myObject)b.Deserialize(s);//s---> is a Stream object that has been fill up with data some line over here
任何一个有想法?
除了下面指出的流位置问题之外,这可能发生的另一个原因是因为您的应用程序在* large *文件写入磁盘之前退出(如果您正在将大量数据序列化到文件流)。要解决这个问题,你需要实现一个阻塞等待,直到文件完全写在这篇文章中:http://stackoverflow.com/questions/10982104/wait-until-file-is-completely-written – 2015-12-11 19:26:47