LocalPath Property

Uri.LocalPath Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets a local operating-system representation of a file name.

Namespace:  System
Assembly:  System (in System.dll)

'Declaration
Public ReadOnly Property LocalPath As String

Property Value

Type: System.String
A String that contains the local operating-system representation of a file name.

ExceptionCondition
InvalidOperationException

This property is valid only for an absolute Uri instance.

The value returned by this property is unescaped. If the path is recognized as a Windows file path, all forward slashes (/) are replaced by backward slashes (\).

For the URI file://computer/file.ext, the absolute path is /file.ext and the local path is \\computer\file.ext.

LocalPath does not convert the forward slash (/) to a backslash (\). This is because file-based URIs (URIs of the form file://) are not allowed. Paths returned are relative paths.

The following example creates a Uri instance and writes the local path to the console.


Dim uriAddress2 As Uri = New Uri("file://server/filename.ext")
outputBlock.Text &= uriAddress2.LocalPath
outputBlock.Text &= vbCrLf

If uriAddress2.IsUnc Then 
  outputBlock.Text &= "Uri is a UNC path"
  outputBlock.Text &= vbCrLf
Else
  outputBlock.Text &= "Uri is not a UNC path"
  outputBlock.Text &= vbCrLf
End If      


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft