Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WebMatrix中单独的.cs文件中的Server.MapPath使用什么using指令?_C#_Asp.net_Webmatrix_Using Directives - Fatal编程技术网

C# WebMatrix中单独的.cs文件中的Server.MapPath使用什么using指令?

C# WebMatrix中单独的.cs文件中的Server.MapPath使用什么using指令?,c#,asp.net,webmatrix,using-directives,C#,Asp.net,Webmatrix,Using Directives,我试图在WebMatrix中的一个单独的.cs文件中使用Server.MapPath() 我可以使用HttpContext.Current.Server.MapPath(“~/SomeDirectory/someFile.txt”) 但我真的必须每次键入HttpContext.Current 是否有任何using指令可以将我的输入缩短为简单的Server.MapPath,就像在.cshtml文件中编码一样 我看了这里,但没有一个答案对我有用。可能是因为其中的答案不针对asp.net-webpag

我试图在WebMatrix中的一个单独的
.cs
文件中使用
Server.MapPath()

我可以使用
HttpContext.Current.Server.MapPath(“~/SomeDirectory/someFile.txt”)

但我真的必须每次键入
HttpContext.Current

是否有任何using指令可以将我的输入缩短为简单的
Server.MapPath
,就像在
.cshtml
文件中编码一样

我看了这里,但没有一个答案对我有用。可能是因为其中的答案不针对asp.net-webpages、WebMatrix环境


另外,如果有一种备忘单可以帮助我使用指令查找C#.net,那么考虑到我的环境,让我知道在哪里可以找到它肯定是一个可接受的答案。

您可以将服务器属性分配给一个变量,以节省键入的时间:

var server = HttpContext.Current.Server;
var file = server.MapPath("~/SomeDirectory/Somefile");
要回答文章标题中提出的问题,请在类文件中使用System.Web指令:

using System.Web;

我不知道有这样的“备忘单”。如果您负担得起并且拥有完整版本的Visual Studio,请体验并越来越熟悉MSDN帮助,Resharper也一样。

您可以将服务器属性分配给变量,以节省键入的时间:

var server = HttpContext.Current.Server;
var file = server.MapPath("~/SomeDirectory/Somefile");
要回答文章标题中提出的问题,请在类文件中使用System.Web指令:

using System.Web;
我不知道有这样的“备忘单”。经验和对MSDN帮助的日益熟悉,如果您负担得起并且拥有完整版本的Visual Studio,Resharper也一样