C# 序列化操作类
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.Serialization.Formatters.Binary; using System.Text; using System.Threading.Tasks; namespace EIMS { [Serializable] public static class _Serializable { public static void _Serialize(string path, object data) { using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write)) { BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(fs, data); } } public static object _Deserialization(string path) { using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read)) { BinaryFormatter formatter = new BinaryFormatter(); return formatter.Deserialize(fs); } } } }