0

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!

1 Answer 1

4

Just use the full namespace:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.