zoukankan      html  css  js  c++  java
  • c# 中config.exe 引发的一些问题

     1 public static void CreateConfig(){
     2         //c#可以添加内置的app.config,我们通过ConfigrationManager类可以
     3         //可以很轻松的操作相关节点,操作的方式,这里不做多介绍,
     4         //引发的问题 当程序编译的时候会自动生成 程序名.config.exe这样格式的文件
     5         //这是我们实际操作保存的配置文件, 如果这个文件丢失的话就需要我们自己判断
     6         //配置文件是否存在,也就是说这个配置只是在编译的时候生成
     7         
     8         
     9         //解决方法
    10         //将app.config设置为嵌入资源类型,通过Assembly获取资源文件流
    11         //将配置重新写到根目录
    12         Assembly ass = Assembly.GetExecutingAssembly();
    13         //路径也可以通过AppDomain.CurrentDomain.SetupInformation.ConfigurationFile 获取配置路径
    14         using (Stream s = ass.GetManifestResourceStream(ass.GetName().Name + ".app.config")) {
    15                 byte[] buf = new byte[(int)s.Length];
    16                 s.Read(buf, 0, buf.Length);
    17                 File.WriteAllBytes(cfPath, buf);
    18             }        
    19         }
  • 相关阅读:
    Six steps to create google map in the HTML5
    Vocabularies on vegetable, fruit, meat etc.
    常用的Windows命令
    sqlhelper
    素材
    sql sever 跨库查询
    在annotation中却会有ERROR: Duplicate entry
    一份Java学习路线图
    Java算法实例集合(2)
    Java编程规范实践
  • 原文地址:https://www.cnblogs.com/alplf123/p/7872231.html
Copyright © 2011-2022 走看看