• DataSet生成gb2312编码的xml


     DataSet ds = new DataSet("terminal");                

    DataTable dt = new DataTable("terminalDev");                

    dt.Columns.Add("devClass", typeof(string));              

     dt.Columns.Add("deviceId", typeof(string));                

    dt.Columns.Add("version", typeof(string));
    DataRow row = dt.NewRow();                

    row["devClass"] = txtPlayerName.Text;                

    row["deviceId"] = txtPlayerNo.Text;                

    row["version"] = txtVersion.Text;
    dt.Rows.Add(row);
    ds.Tables.Add(dt);
    string setPath = String.Format("{0}Terminal\\terminal.xml",GetCurrentPath()) ;     //GetCurrentPath()是应用程序路径           

    if (ds != null)                 

    {                    

    FileStream fs = new FileStream(setPath, FileMode.Create);                    

    XmlTextWriter xtr = new XmlTextWriter(fs, System.Text.Encoding.GetEncoding("gb2312"));                    

    //加入了下面的指定就可以了                     

    xtr.Formatting = Formatting.Indented;                  

     xtr.Indentation = 6;                    

    xtr.WriteStartDocument();                    

    ds.WriteXml(xtr);                    

    xtr.Close();                    

    fs.Close();                 

    }

  • 相关阅读:
    http
    python的列表生成式
    flask的登陆验证
    脚本更新流程
    k8s中job和pod的区别
    k8s中一些常见概念
    supervisord部署和使用
    flask中config
    python类的继承super()的使用
    python中类的继承
  • 原文地址:https://www.cnblogs.com/uwking/p/2042308.html
Copyright © 2020-2023  润新知