Uri.LocalPath Uri.LocalPath Uri.LocalPath Uri.LocalPath Property

Définition

Obtient une représentation du système d'exploitation local d'un nom de fichier.Gets a local operating-system representation of a file name.

public:
 property System::String ^ LocalPath { System::String ^ get(); };
public string LocalPath { get; }
member this.LocalPath : string
Public ReadOnly Property LocalPath As String

Valeur de propriété

String qui contient la représentation du système d'exploitation local d'un nom de fichier.A String that contains the local operating-system representation of a file name.

Exceptions

Cette instance représente un URI relatif, et cette propriété est uniquement valide pour les URI absolus.This instance represents a relative URI, and this property is valid only for absolute URIs.

Exemples

L’exemple suivant crée une Uri instance et écrit le chemin d’accès local dans la console.The following example creates a Uri instance and writes the local path to the console.

Uri^ uriAddress2 = gcnew Uri( "file://server/filename.ext" );
Console::WriteLine( uriAddress2->LocalPath );
Console::WriteLine( "Uri {0} a UNC path", uriAddress2->IsUnc ? (String^)"is" : "is not" );
Console::WriteLine( "Uri {0} a local host", uriAddress2->IsLoopback ? (String^)"is" : "is not" );
Console::WriteLine( "Uri {0} a file", uriAddress2->IsFile ? (String^)"is" : "is not" );
// The example displays the following output:
//    \\server\filename.ext
//    Uri is a UNC path
//    Uri is not a local host
//    Uri is a file
Uri uriAddress2 =  new Uri("file://server/filename.ext");
Console.WriteLine(uriAddress2.LocalPath);
Console.WriteLine("Uri {0} a UNC path", uriAddress2.IsUnc ? "is" : "is not");
Console.WriteLine("Uri {0} a local host", uriAddress2.IsLoopback ? "is" : "is not");
Console.WriteLine("Uri {0} a file", uriAddress2.IsFile ? "is" : "is not");
// The example displays the following output:
//    \\server\filename.ext
//    Uri is a UNC path
//    Uri is not a local host
//    Uri is a file
Dim uriAddress2 As New Uri("file://server/filename.ext")
Console.WriteLine(uriAddress2.LocalPath)
Console.WriteLine("Uri {0} a UNC path", IIf(uriAddress2.IsUnc, "is", "is not")) 'TODO: For performance reasons this should be changed to nested IF statements
Console.WriteLine("Uri {0} a local host", IIf(uriAddress2.IsLoopback, "is", "is not")) 'TODO: For performance reasons this should be changed to nested IF statements
Console.WriteLine("Uri {0} a file", IIf(uriAddress2.IsFile, "is", "is not")) 'TODO: For performance reasons this should be changed to nested IF statements
' The example displays the following output:
'    \\server\filename.ext
'    Uri is a UNC path
'    Uri is not a local host
'    Uri is a file

Remarques

La valeur retournée par cette propriété est sans séquence d’échappement.The value returned by this property is unescaped. Si le chemin d’accès est reconnu comme un chemin d’accès de fichier Windows, toutes les barres obliques (/) sont\remplacées par des barres obliques inverses ().If the path is recognized as a Windows file path, all forward slashes (/) are replaced by backward slashes (\).

Pour l’URI file://computer/file.ext, le chemin d’accès /file.ext absolu est et le chemin \\computer\file.extd’accès local est.For the URI file://computer/file.ext, the absolute path is /file.ext and the local path is \\computer\file.ext.

S’applique à