MSDN Library
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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)

public string LocalPath { get; }

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.


Uri uriAddress2 =  new Uri("file://server/filename.ext");
outputBlock.Text += uriAddress2.LocalPath;
outputBlock.Text += "\n";

if (uriAddress2.IsUnc) 
    outputBlock.Text += "Uri is a UNC path\n";
else
    outputBlock.Text += "Uri is not a UNC path\n";


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2016 Microsoft