使用Server.Mappath() [英] Server.MapPath()

查看:275
本文介绍了使用Server.Mappath()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用使用Server.Mappath()方法IM为了映射虚拟目录 我创建它的物理路径。

I want to use Server.MapPath() method im order to map a virtual directory I created to its physical path.

的事情是,.NET环境不承认使用Server.Mappath()。

The thing is that the .net environment doesn't recognize Server.MapPath().

谷歌告诉我,我应该HttpContext.Current.Server使用的System.Web使用, 但HttpContext的是,尽管我使用的System.Web无法识别。 (而且我已经检查 - HttpContext的IS的System.Web中的类之一)

Google told me I'm supposed to use HttpContext.Current.Server using System.Web, but HttpContext isn't recognized in spite of me using System.Web. (And I've checked - HttpContext IS one of System.Web's classes)

帮助?

推荐答案

如果你有一个Web应用程序,您应具有自动引用 System.Web.dll中,你应该有机会获得 System.Web.HttpContext 类。请检查您是否不小心删除了参考。您将需要一个使用的System.Web; 语句访问的HttpContext 类,而无需指定完整的命名空间。

If you have a web application, you should automatically have a reference to System.Web.dll, and you should have access to the System.Web.HttpContext class. Check that you haven't accidentally removed the reference. You would need a using System.Web; statement to access the HttpContext class without specifying the complete namespace.

如果你没有一个Web应用程序,你将有一个referece添加到 System.Web.dll中来获得访问的HttpContext 类,但不会帮助你一点。由于你是不是在一个Web应用程序,没有HTTP上下文,也没有Web根文件夹中,这样你就不能使用MapPath方法。

If you don't have a web application you would have to add a referece to System.Web.dll to get access to the HttpContext class, but that would not help you a bit. As you are not in a web application, there is no HTTP context and there is no web root folder, so you can not use the MapPath method.

这篇关于使用Server.Mappath()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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