public void SerializeObject(object o,string path) { System.Runtime.Serialization.IFormatter obj = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); Stream oS = new FileStream(path,FileMode.Create,FileAccess.Write,FileShare.Write); obj.Serialize(oS,o); oS.Close(); oS = null; o = null; return ;
} // public object DeserializeObject(string path) { if(!File.Exists(path)) return null; FileStream oS = new FileStream(path,FileMode.Open,FileAccess.Read,FileShare.None); System.Runtime.Serialization.IFormatter obj = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); object o; try { o = obj.Deserialize(oS); } catch(System.Exception e) { throw (e); } finally { oS.Close(); oS= null;
{
System.Runtime.Serialization.IFormatter obj = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
Stream oS = new FileStream(path,FileMode.Create,FileAccess.Write,FileShare.Write);
obj.Serialize(oS,o);
oS.Close();
oS = null;
o = null;
return ;
}
//
public object DeserializeObject(string path)
{
if(!File.Exists(path))
return null;
FileStream oS = new FileStream(path,FileMode.Open,FileAccess.Read,FileShare.None);
System.Runtime.Serialization.IFormatter obj = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
object o;
try
{
o = obj.Deserialize(oS);
}
catch(System.Exception e)
{
throw (e);
}
finally
{
oS.Close();
oS= null;
obj = null;
}
return o;
}