首页 > 编程语言 >C# 序列化操作类

C# 序列化操作类

时间:2023-04-29 17:13:00浏览次数:40  
标签:formatter using C# System FileStream fs path 操作 序列化

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

相关文章

  • C# MD5 加密操作类
    usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Globalization;usingSystem.Security.Cryptography;usingSystem.IO;usingSystem.ServiceModel;namespaceEIMS{publicstaticclassMD5Helper{#regionMD5加密......
  • HZNUCTF2023
    前言还是要向大师傅们orz,本人太菜了。希望大师傅们可以来指点本菜鸡,让本坤能快点理解wp,QAQ。easy_rw查保护,和禁用系统调用静态分析程序漏洞。程序功能很简单,就是一个栈溢出。但是仅溢出0x28字节,本人思路是先泄露libc,再打一个栈迁移。expfrompwncyimport*context(arch......
  • Educational Codeforces Round 145 (Rated for Div. 2)
    Preface补题A~D都能秒出,E没看出性质被薄纱了,F感觉是个丁真题随便讨论下就过了后面看了下F的标算是个倍增,感觉Tutorial对性质挖掘的还不够的说A.GarlandSB题,设出现次数最多的颜色个数为\(cm\),若\(cm\le2\)则答案为\(4\);若\(cm=3\)则答案为\(6\),若\(cm=4\)则无解importjav......
  • MIS501 Case Study
    MIS501Assessment3CaseStudyPage1CaseStudyImpressedbyyourprogramsimplementedinAssessment2,thestakeholdersoftherestauranthaveaskedyoutodevelopaprogramextendingAssessment2.Inthisassessment,youwillhavetousetheObjectOrienta......
  • 希望所有计算机学生能看到这篇c语言教程
    大部分程序员走入编程世界第一个学习的语言就是C语言。作为一门古老的编程语言,c语言拥有48年的发展历程。为什么要学习C语言?C语言是学习计算机程序设计语言的入门语言。最全面的编程面试网站C语言是一门偏底层的语言,学好它,可以让你更好的了解计算机。学会了C语言,你就能学习......
  • MFC-SetItemText设置文本
     BOOLbb=mylist4.SetItemText(0,1,_T("87"));//设置文本/*参数1:int项索引-行号【从0开始不包括标题栏】参数2:列号参数3:LPCTSTR文本返回值:成功返回非0,失败返回0*/  ......
  • CodeForces-858#C 题解
    正文♦最坏时间复杂度:\(\mathcal{O}(\lvertS\rvert)\)本题十分简单,但请注意两个条件要同时满足。因为要求分割的次数越少越好,所以只要连续的辅音字母长度不大于2就不需要分割。由于辅音字母太多,只需要标记元音字母即可。#include<iostream>#include<string>#include<cst......
  • docker 创建mysql及卷挂载
    dockerpullmysql:5.7dockerrun-d-p3307:3306-v/home/mysql/conf:/etc/mysql/conf.d-v/home/mysql/data:/var/lib/mysql-eMYSQL_ROOT_PASSWORD=root--namemysql57mysql:5.7----------------------------------------------d后台运行-p3307:3306端口映射-v......
  • Spring RCE漏洞
    SpringRCE漏洞目录SpringRCE漏洞一、漏洞概况与影响二、Spring动态参数绑定三、漏洞复现四、漏洞原理五、漏洞排查和修复一、漏洞概况与影响CVE编号:CVE-2022-22965受影响范围:SpringFramework5.3.X<5.3.18SpringFramework5.2.X<5.2.20JDK>=9使用Tomcat中间件且......
  • #yyds干货盘点# LeetCode程序员面试金典:组合总和 II
    题目:给定一个候选人编号的集合 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。candidates 中的每个数字在每个组合中只能使用 一次 。注意:解集不能包含重复的组合。  示例 1:[10,1,2,7,6,1,5]8示例 2:输入:candidates=[......