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); } } } }
标签:formatter,using,C#,System,FileStream,fs,path,操作,序列化 From: https://www.cnblogs.com/jianxiaoxiu/p/17364235.html