获取IIS应用程序文件系统路径 [英] Getting IIS Application filesystem path

查看:707
本文介绍了获取IIS应用程序文件系统路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有IIS安装在PC MNY 7.0。
我有一个.SVC服务有一个.NET应用程序。

I have IIS 7.0 installed in mny pc. I have a .net application with a .svc service there.

我想指出一个文件应用程序指向虚拟目录(请注意,我将我的虚拟目录中的应用程序)。

I would like to point a file in the virtual directory pointed by the application (please note that I converted my virtual dir in an application).

然而,当我试图打开一个文件,使用.NET诗句一般的API调用,并且不指定根(完整的)路径,但相对的,我在错误结束时未找到资源

However, when I try to open a file, using a general api call in the .net-verse, and do not specify a root (complete) path but relative, I end up in the error when a resource is not found.

我怎样才能获得我的应用程序的物理路径?

How can I obtain the physical path of my app?

请注意,我说的是一个Web应用程序。但是,因为我需要从我的web服务,通​​过我的应用程序托管拨打这个电话,我不能使用请求对象。

Please note that I am talking about a web application. But I cannot use the Request object because I need to make this call from my web service, hosted by my app.

三江源

推荐答案

试试这可能有助于解决您的问题。

try this might help to resolve your issue

string apPath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;

string apPath = System.Web.Hosting.HostingEnvironment.MapPath("~/folder/file");

这篇关于获取IIS应用程序文件系统路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆