就是我建立了一个solution  下面有多个工程 想使用同一个appconfig  直接  添加现有项  不行  因为程序会自动复制一个副本到每个工程的文件夹下

解决方案 »

  1.   

    是工程之间的引用吗?
     配置文件我想其实最好用XML保存.不过那样不安全...
      

  2.   

    不行喇  一个项目只能有一个congigu
      

  3.   

    你是保存什么信息?
      推荐你使用'内裤' *.DLL
     前提不是敏感数据,如果是某些敏感数据
     用另外的方式.'内裤'就只能加壳子.
      

  4.   

    可以自己写个类 读取APP.Configusing System;
    using System.Collections.Generic;
    using System.Text;
    using System.Xml;
    using System.Windows.Forms;namespace DataCrypto
    {
        public class AppSettings
        {
            public static string AppConfig()
            {
                return System.IO.Path.Combine(Application.StartupPath, "App.config");//此处配置文件在程序目录下
            }        public static string GetValue(string appKey)
            {
                XmlDocument xDoc = new XmlDocument();
                try
                {
                    xDoc.Load(AppSettings.AppConfig());
                    XmlNode xNode;
                    XmlElement xElem;
                    xNode = xDoc.SelectSingleNode("//appSettings");
                    xElem = (XmlElement)xNode.SelectSingleNode("//add[@key='" + appKey + "']");
                    if (xElem != null)
                        return xElem.GetAttribute("value");
                    else
                        return "";
                }
                catch (Exception)
                {
                    return "";
                }
            }        public static void SetValue(string AppKey, string AppValue)
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.Load(AppSettings.AppConfig());
                XmlNode xNode;
                XmlElement xElem1;
                XmlElement xElem2;
                xNode = xDoc.SelectSingleNode("//appSettings");
                xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
                if (xElem1 != null)
                {
                    xElem1.SetAttribute("value", AppValue);
                }
                else
                {
                    xElem2 = xDoc.CreateElement("add");
                    xElem2.SetAttribute("key", AppKey);
                    xElem2.SetAttribute("value", AppValue);
                    xNode.AppendChild(xElem2);
                }
                xDoc.Save(AppSettings.AppConfig());
            }
        }
    }