如何获取当前项目目录或bin目录并向上移动几级?
我有一个 ASP.Net MVC 应用程序,并且在 Content 目录中有一些 xsl 文件。 我尝试了几种方法来动态获取目录,但仍然不够。
那么如何让目录指向 Content/xsl 文件夹呢?
我最接近的是:
this.GetType().Assembly.CodeBase
它只返回项目 DLL,但我不知道如何从那里向上移动几个级别,也不知道使用什么 .net 库来导航路径。
没有 ../.. :(
基本上我想导航到与 Bin 目录处于同一级别的 Content/xsl 文件夹。
I have an ASP.Net MVC app, and i have some xsl files inside of the Content directory.
I've try a few methods to get directory dynamically buy keep on coming short.
So how do i get the directory to point to the Content/xsl folder?
the closest that i came to was with this:
this.GetType().Assembly.CodeBase
which only returns the project DLL, but i can't figure out how to move up a few levels from there or what .net library to use to navigate around the path.
there's no ../.. :(
Basically i want to navigate to the Content/xsl folder which is at the same level of the Bin directory.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该
Server.MapPath
为此。You should
Server.MapPath
for this.