zoukankan      html  css  js  c++  java
  • List<string>转xml

      /// <summary>
            /// List<string>转xml
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button1_Click(object sender, EventArgs e)
            {
                try
                {
                    List<string> std = new List<string>();
                    for (int irow = 0; irow < standardcells.Count(); irow++)
                    {
                        List<ICell> row = standardcells[irow];
                        for (int icol = 0; icol < row.Count(); icol++)
                        {
                            std.Add(row[icol].StringCellValue);
                        }
                    }
    
                    using (System.IO.StringWriter stringWriter = new StringWriter(new StringBuilder()))
                    {
                        XmlSerializer xmlSerializer = new XmlSerializer(typeof(List<string>));
                        xmlSerializer.Serialize(stringWriter, std);
    
                        FileStream fs = new FileStream("list_userModel.xml", FileMode.OpenOrCreate);
                        StreamWriter sw = new StreamWriter(fs);
                        sw.Write(stringWriter.ToString());
                        sw.Close();
                        fs.Close();
                        MessageBox.Show("写入文件成功!");
                    }
                }
                catch (System.Exception ex)
                {
                    System.Console.WriteLine("====================================");
                    System.Console.WriteLine(ex.Message);
                    System.Console.WriteLine(ex.StackTrace);
                }
    
            }
  • 相关阅读:
    进程二
    高德地图api的使用
    《架构即未来》读后感3
    三周总结
    性能战术:
    二周总结
    《 架构即未来》读后感2
    一周总结
    《架构即未来》读后感
    学生信息系统dao层
  • 原文地址:https://www.cnblogs.com/wmm-pcy/p/9752832.html
Copyright © 2011-2022 走看看