user3627450
user3627450

Reputation: 55

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!

Upvotes: 0

Views: 533

Answers (1)

DavidG
DavidG

Reputation: 119136

Just use the full namespace:

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

Upvotes: 4

Related Questions