ASP.NET sets the path for a file with VB

So this is a pretty stupid question, and I obviously misunderstand for some reason. I have an ASP.net project, and the aspx page by default loads the file. I created a class for processing files, in it I hardcoded the local directory where this file is located. I want to make this path relative to the default.aspx page. I canโ€™t figure out how to do this. I read a lot of material on MSDN, and this makes simple sense, but when I put it in code, I canโ€™t figure out what is right.

I feel that my answer is here, I understand what he is saying, but I cannot translate this into my program. http://msdn.microsoft.com/en-us/library/ms178116.aspx . Code for example

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

makes sense to me, but I canโ€™t use the โ€œServerโ€ for some reason.

I have used this code point to complement my problem at the moment.

 string=System.AppDomain.CurrentDomain.BaseDirectory() 

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

+4
source share
1 answer

Try

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

from your class.

+4
source

All Articles