获取.Net库中文件的路径
我的库项目正在尝试从库中也包含的文件打开 XmlDocument。如何获取库中文件的路径以便打开它?
当前目录没有用,Server.MapPath 返回主 Web 应用程序 (MVC) 的路径,那么如何获取库中文件的路径呢?
- - - - 编辑 xml 文件位于库项目内的一个文件夹中,该文件夹在部署时不存在。因此,这些文件似乎需要存在于库外部的文件夹中(例如 IIS 中的虚拟目录)。
史蒂夫
My library project is trying to open an XmlDocument from a file that's also contained in the library. How do I get the path of a file in the library so I can open it?
The current directory is not useful and Server.MapPath returns me the path of the main web application (MVC), so how do I get the path of the file in the library?
------- Edit
The xml files are in a folder within the library project which wont exist when deployed. So it seems these files need to exist in a folder outside of the library (in a virtual directory in IIS for instance).
Steve
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您正在查找当前正在执行的程序或程序集的路径(我不确定您是不是),请使用您要查找的
Assembly
的Location
属性重新感兴趣:或
If you're looking for the path of the currently-executing program or assembly (I'm not sure that you are), use the
Location
property of theAssembly
you're interested in:or