简体   繁体   中英

Server.MapPath for a custom class?

I'm trying to use

Server.MapPath

In my file location, which has worked perfectly so far in my project, however now I have ceated a new class inside the App_Code folder in my site and I can no longer use "Server" ,I get the error

"Error 4 The name 'Server' does not exist in the current context"

How can I fix this? I would like to be able to use Server.MapPath instead of alternatives as I have already done this for the rest of the site, so is there anyway? If not what are my alternatives?

I also tried

~\\App_Code\\myfile

But this didn't work either. Thanks!

只需使用完整的名称空间:

HttpContext.Current.Server.MapPath(...);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM