数据集的序列化方法 [英] serialization methods for a DataSet
本文介绍了数据集的序列化方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨...
我曾尝试对DataSet使用序列化方法
图片中的问题:
[img] http://www5.0zz0.com/2012/01/20/09/288177525.jpg [/img]
序列化方法:
hi...
i was try to use a serialization methods for a DataSet
the probleme in the picture:
[img]http://www5.0zz0.com/2012/01/20/09/288177525.jpg[/img]
serialization methods:
/*************************************************/
public static void Serialize(DataSet ds, Stream stream)
{
BinaryFormatter serializer = new BinaryFormatter();
serializer.Serialize(stream, ds);
}
public static DataSet Deserialize(Stream stream)
{
BinaryFormatter serializer = new BinaryFormatter();
return (DataSet)serializer.Deserialize(stream);
}
/***************************************************/
问题的信息:"Fin de fluxrencontréeavant la fin de l''analyse."
[edit]英语错误消息:解析完成之前遇到流结束" [/edit]
在指令中:return(DataSet)serializer.Deserialize(stream);
帮帮我...
message of probleme: "Fin de flux rencontrée avant la fin de l''analyse."
[edit]English error message: "End of Stream Encountered before parsing was complete"[/edit]
in the instruction: return (DataSet)serializer.Deserialize(stream);
help me...
推荐答案
http://stackoverflow.com/questions/306596/end-of-目标已完成stream-encountered-before-parsing [ ^ ]
Hi,
http://stackoverflow.com/questions/306596/end-of-stream-encountered-before-parsing-was-completed[^]
如果您使用相同的流进行反序列化和序列化,请确保将流设置回到位置0.
In case you''re using the same stream for deserialization and serialization, make sure to set your stream back to position 0.
public static DataSet Deserialize(Stream stream)
{
BinaryFormatter serializer = new BinaryFormatter();
stream.Position=0;
return (DataSet)serializer.Deserialize(stream);
}
这篇关于数据集的序列化方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文