• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
bobird的学习笔记
博客园    首页    新随笔    联系   管理    订阅  订阅

C# Hashtable的序列化(保存和读取)

  1. 文章出处:http://blog.csdn.net/lab2013/article/details/7181299
  2. using System.IO;  
  3. using System.Runtime.Serialization.Formatters.Binary;  
  4. ....  
  5. ...  
  6.   
  7. Hashtable aa = new Hashtable();  
  8.   
  9. private void buttonSave_Click(object sender, EventArgs e)  
  10. {  
  11.     FileStream fs = new FileStream("e:\\aa.dat", FileMode.Create);  
  12.     BinaryFormatter bf = new BinaryFormatter();  
  13.     bf.Serialize(fs, aa);  
  14.     fs.Close();  
  15. }  
  16.   
  17. private void buttonLoad_Click(object sender, EventArgs e)  
  18. {  
  19.     aa.Clear();  
  20.     FileStream fs = new FileStream("e:\\aa.dat", FileMode.OpenOrCreate);  
  21.     BinaryFormatter bf = new BinaryFormatter();  
  22.     aa = (Hashtable)bf.Deserialize(fs);  
  23.     fs.Close();  
  24. }  
posted on 2013-01-05 13:06  bobird  阅读(850)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3