The MapPath method

The ASP.NET Page object exposes the MapPath method, which converts a virtual path into a physical path, so it’ is useful for passing arguments to objects that don’t work with virtual paths:

Dim sr As New System.IO.StreamReader(Me.MapPath(“/data/values.dat”))

You can also use MapPath to retrieve information onabout the current ASP.NET application, for exampleas you see in this snippet:

' The current directory Dim currDir As String = Me.MapPath(".") ' The parent directory Dim parentDir As String = Me.MapPath("..") ' The root directory Dim rootDir As String = Me.MapPath("/")
%d bloggers like this: