大家好 我现在要修改一个C#的工程,但我本身是搞C++的,C#没经验,我在app.config.xml里发现一个字段是需要修改的,但我不知道能不能直接修改它。

解决方案 »

  1.   

    可以直接修改,建议在修改之前备份原来的App.config
      

  2.   

    不好意思   我现在对这个config文件搞的有点糊涂,  发布exe的时候还要一起发布app.exe.config吗?
      

  3.   

    http://hi.baidu.com/libinguest/blog/item/31a5338726d0b023c65cc384.html不过建议新增一个XML文件存储应用程序级相关信息
      

  4.   

    给由c++转到C#的程序员建议:
    多按照软件使用者的角度考虑,少从机器的角度考虑问题。C#封装的太多了,使之更适合“门外汉”入门,微软称之为对程序员更友好,什么问题都为你考虑。连配置文件都有.net 框架支持。
      

  5.   

    这个app.exe.config是怎么产生的呢?  我把release目录下的app.exe.config删掉了,重新生成却没有生成它,难道在别的目录?还是要把app.config复制过来再改名?
    先汗自己一个
      

  6.   


    是系统自动生成的。注意vs环境里的debug和release模式。
      

  7.   

    app.config修改
    Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
      config.AppSettings.Settings.Remove(key);
      config.AppSettings.Settings.Add(key, value);
      config.Save(ConfigurationSaveMode.Modified);
      ConfigurationManager.RefreshSection("appSettings");   string configFileName = Application.ExecutablePath + ".config";  
    System.Xml.XmlDocument doc = new System.Xml.XmlDocument();  
    doc.Load(configFileName);  
    string configString = @"";  
    System.Xml.XmlNode configNode = doc.SelectSingleNode(configString);  
    if (configNode != null)  
    {  
      configNode.InnerText = "";  
      doc.Save(configFileName);  
      Properties.Settings.Default.Reload();   
    }