Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why can't I use MapPath() from a vb class?

Status
Not open for further replies.

christheprogrammer

Programmer
Jul 10, 2000
258
CA
Hi, I hava a standalone class (it is not a codebehind class) that I wish to use MapPath in. The reason is that I have user directories stored in an XML file along with passwords, etc. and I want to be able to access them from whatever location the pages will actually reside.. I want to do this:

Directory.CreateDirectory(MapPath(".") & "\Users\bob\")

Anyone know? Chris says: "It's time for a beer."
 
let me rephrase the question:
I know I why I can't use MapPath() from a VB class, it is a Page method. Is there something else I can use to get the path of the codefile?

Thanks Chris says: "It's time for a beer."
 
The reason is that MapPath is a page method like you said, this means that if you want to access a page method from a seperate class, you have to do it via the HTTPCurrentContext object like: HTTPCurrentContext.MapPath

Via this object you can access all the methods and values from the page that has created your object as if it were included in the page.

Good luck
 
Thanks, I may try that, but for now I am passing MapPath(".") from a page code-behind file to the constructor of the seperate class, and storing it as a private member variable. It works, but is not really elegant.
Cheers Chris says: "It's time for a beer."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top