第一种方式: 

HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["DataAddress"].ToString());

 

第二种方式:

           string dataAdress = ConfigurationManager.AppSettings["DataAddress"];
            string bathPath = AppDomain.CurrentDomain.BaseDirectory;
            string path = bathPath.Substring(0, bathPath.LastIndexOf('\\', bathPath.Length - 2)) + dataAdress;

 

 

显然第一种方式简洁


本文转载:CSDN博客