static void SaveAsBinaryFormat(object obj,string filename)
{
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter binFormat =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
using(System.IO.Stream fsStream = new System.IO.FileStream(filename,System.IO.FileMode.Create,
System.IO.FileAccess.Write,System.IO.FileShare.None))
{
binFormat.Serialize(fsStream, obj);
}
}