Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 wcf 服务中有一个简单的 xml 文件,我正在尝试使用未读取文件的 Xelement.Load("sample.xml") 加载该文件。这样做的正确方法是什么?
该服务应该将 xml 返回到 asp.net 应用程序。
TIA
我通过提供绝对路径作为 XElement.Load() 方法的参数来使其工作,但相对路径会更好。
你应该尝试这样的事情。
var appPath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath; bodyFile = Path.Combine(appPath, @"<File Name Path");
这将相对于您的应用程序的物理路径起作用。