devxlogo

The MapPath method

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 directoryDim parentDir As String = Me.MapPath("..")' The root directoryDim rootDir As String = Me.MapPath("/")

devx-admin

Share the Post: