如何获取当前项目目录或bin目录并向上移动几级?

发布于 2024-09-02 20:47:15 字数 319 浏览 2 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独守阴晴ぅ圆缺 2024-09-09 20:47:15

您应该 Server.MapPath 为此。

You should Server.MapPath for this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文