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);
                }
    
            }
  • 相关阅读:
    小程序 scroll-view 中文字不换行问题
    模块
    网络编程
    元类
    day24
    day23
    day22
    day21
    day18
    day17
  • 原文地址:https://www.cnblogs.com/wmm-pcy/p/9752832.html
Copyright © 2011-2022 走看看