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.
Assembly: System (in System.dll)
Property Value
Type: System.StringA String that contains the local operating-system representation of a file name.
| Exception | Condition |
|---|---|
| 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