惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Y
Y Combinator Blog
G
Google Developers Blog
Vercel News
Vercel News
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Jina AI
Jina AI
Blog — PlanetScale
Blog — PlanetScale
H
Help Net Security
博客园 - 三生石上(FineUI控件)
MongoDB | Blog
MongoDB | Blog
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
H
Hackread – Cybersecurity News, Data Breaches, AI and More
aimingoo的专栏
aimingoo的专栏
T
Tailwind CSS Blog
博客园 - 叶小钗
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
Microsoft Security Blog
Microsoft Security Blog
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG

博客园 - myer

使用you-get下载youtube视频 找不到org.springframework.context.ConfigurableApplicationContext的类文件 Centos7安装mysql8 无法加载oramts.dll 反射应用中的同种类型转换错误 - myer - 博客园 aspx文件生产静态html文件 在ASP.NET中实现Url Rewriting 正则表达式 c# 手机号码正则表达式 - myer - 博客园 jscalendar-1.0中文解决方法 GridView中嵌套GridView asp.net 小偷程序实现的原理和源码 - myer - 博客园 GridView 排序 开源软件FtpClient几个问题 CMM简介 C# ping命令的实现 DIV模式窗口的实现 ASP.net 本地化和国际化 C#编码规范
.net中序列化和反序列化
myer · 2007-03-25 · via 博客园 - myer

string filePath = "data.xml";//定义文件名
                DataSet ds = new DataSet();
                if (!File.Exists(Server.MapPath(filePath)))
                {
                    ds = 数据;//取数据
                    //序列化
                    BinaryFormatter bin = new BinaryFormatter();
                    StreamWriter dat = new StreamWriter(Server.MapPath(filePath));
                    bin.Serialize(dat.BaseStream, ds);
                    dat.Close();
                }
                else
                {
                    //反序列化
                    BinaryFormatter bin = new BinaryFormatter();
                    StreamReader sr = new StreamReader(Server.MapPath(filePath));
                    ds = (DataSet)bin.Deserialize(sr.BaseStream);
                    sr.Close();
                }