本帖最后由 monibu 于 2009-08-15 15:08:19 编辑

解决方案 »

  1.   

    参考这里
    http://www.cnblogs.com/gerry-bj/archive/2008/08/06/1261712.html
      

  2.   

    诶~~不知道怎么说好,反正使用
    System.Configuration.ConfigurationManager.AppSettings或者
    System.Configuration.ConfigurationManager.ConnectionStrings
    都不行
      

  3.   

    <add key="LogPath"> D:\Log\</add>这个样的形式我比较熟悉 是element.innertext  获得D:\Log\你那个也有函数 但是我给忘了 只记得这个
      

  4.   

    Response.Write(ConfigurationManager.AppSettings["DefaultDataSource"]);
    Response.Write(ConfigurationManager.ConnectionStrings["SqlServer"]);
      

  5.   

    using System.Configuration;
    Response.Write(ConfigurationManager.AppSettings["DefaultDataSource"]); 
    Response.Write(ConfigurationManager.ConnectionStrings["SqlServer"]);
      

  6.   

     ConfigurationManager.ConnectionStrings["MySql"].ToString();
            ConfigurationManager.AppSettings["DefaultDataSource"].ToString();
      

  7.   

            /// <summary>
            /// 取配置项:日志文件路径
             /// </summary>
            /// <returns></returns>
            public static string GetLogPath()
            {
                HttpResponse Response;
                string logpath = Response.Write
                   (ConfigurationManager.AppSettings["LogPath"]);

                return logpath;
            }错误 1 无法将类型“void”隐式转换为“string”
      

  8.   

      (ConfigurationManager.AppSettings["LogPath"]);  tostring 一下
      

  9.   

    解决了:
                string strReturn = "";
                XmlNode node = m_Doc.SelectSingleNode("//appSettings/LogPath");
                if (node != null)
                {
                    strReturn = node.InnerText.Trim();
                }
                else
                {
                    strReturn = "";
                }
                return strReturn;
    顺便修改了下XML文件:
              <LogPath>D:\Log\</LogPath>
      <DefaultDataSource>SqlServer</DefaultDataSource>
      

  10.   

       string staticConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStrings"].ConnectionString;(ConfigurationManager.AppSettings["LogPath"]);  
      

  11.   

    看大家的答案  采用的是2种方法
    1种是直接读XML文件的方式。
    1种是.NET下 运用System.Configuation类来读 配置文件的方法,一般是Web.config