Server.MapPath
方法。<appSettings>
<add key="filePath" value= "App_Data/Physicians.xml" />
</appSettings>
string relativePath = ConfigurationManager.AppSettings["filePath"];
string combinedPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, relativePath)
后一种技术可以在非网络应用中使用,因此可以说它更好。