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();
                }

相关文章:

  • 2021-06-08
  • 2022-03-05
  • 2021-08-02
  • 2022-02-13
  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
  • 2022-02-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
  • 2021-05-24
  • 2021-06-28
相关资源
相似解决方案