• winform中读取嵌入的xml文件


     System.Reflection.Assembly thisExe = System.Reflection.Assembly.GetExecutingAssembly();
    string xmlPath = string.Empty; 
    xmlPath = "AutoCode.BLL.xml";// "名称空间.文件名.xml" 注意xml必须放到项目的根目录,放入文件夹里无效。记得xml文件要是utf-8编码
     System.IO.Stream xmlr = thisExe.GetManifestResourceStream(xmlPath);
    StreamReader sr = new StreamReader(xslr,Encoding.UTF8);

    string str= sr.ReadToEnd();

    File.Delete("temp.xml");
    File.AppendAllText("temp.xml", str, Encoding.UTF8);//写到xml文件

  • 相关阅读:
    制作文件的备份
    文件的读写
    文件的打开与关闭
    文件操作介绍
    数据类型转换
    位运算
    进制
    函数使用注意事项
    匿名函数
     递归函数
  • 原文地址:https://www.cnblogs.com/zhuawang/p/2130224.html
Copyright © 2020-2023  润新知