sean kenney
sean kenney

Reputation: 43

ASP.NET setting a path for file with VB

So this is a pretty dumb question, and one I am clearly misunderstanding for whatever the reason. I have an ASP.net project and the default aspx page loads a file. I made a class to deal with file handling, in it I hard coded the local directory to where that file is. I want to make that path relative to the default.aspx page. I can't figure out how to do that. I have read a lot of stuff on MSDN, and it makes simple sense, but when I put it to code I can't seem to get it right.

I feel my answer is here, I understand what it is saying but I can't translate that to my program.http://msdn.microsoft.com/en-us/library/ms178116.aspx. Code such as

Dim rootPath As String = Server.MapPath("~")

makes sense to me but I can't use 'Server' for some reason.

I have used this spot of code to supplement my problem for now.

string=System.AppDomain.CurrentDomain.BaseDirectory()

Any help leading me on the right....path, would be appreciated.

Upvotes: 4

Views: 1367

Answers (1)

Bala R
Bala R

Reputation: 108957

Try

Dim rootPath As String = HttpContext.Current.Server.MapPath("~")

from your class.

Upvotes: 4

Related Questions