ManagementPath.RelativePath 属性   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置相对路径:只包含类名和键。
public:
 property System::String ^ RelativePath { System::String ^ get(); void set(System::String ^ value); };
	public string RelativePath { get; set; }
	member this.RelativePath : string with get, set
	Public Property RelativePath As String
	属性值
返回一个 String 值,该值包含相对路径。
示例
以下示例演示 类如何 ManagementPath 分析 WMI 对象的路径。 示例中分析的路径是类实例的路径。
using System;
using System.Management;
public class Sample
{
    public static void Main()
    {
        // Get the WMI class path
        ManagementPath p =
            new ManagementPath(
            "\\\\ComputerName\\root" +
            "\\cimv2:Win32_LogicalDisk.DeviceID=\"C:\"");
        Console.WriteLine("IsClass: " +
            p.IsClass);
        // Should be False (because it is an instance)
        Console.WriteLine("IsInstance: " +
            p.IsInstance);
        // Should be True
        Console.WriteLine("ClassName: " +
            p.ClassName);
        // Should be "Win32_LogicalDisk"
        Console.WriteLine("NamespacePath: " +
            p.NamespacePath);
        // Should be "ComputerName\cimv2"
        Console.WriteLine("Server: " +
            p.Server);
        // Should be "ComputerName"
        Console.WriteLine("Path: " +
            p.Path);
        // Should be "ComputerName\root\cimv2:
        // Win32_LogicalDisk.DeviceId="C:""
        Console.WriteLine("RelativePath: " +
            p.RelativePath);
        // Should be "Win32_LogicalDisk.DeviceID="C:""
    }
}
Imports System.Management
Public Class Sample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer
        ' Get the WMI class path
        Dim p As ManagementPath = _
            New ManagementPath( _
            "\\ComputerName\root" & _
            "\cimv2:Win32_LogicalDisk.DeviceID=""C:""")
        Console.WriteLine("IsClass: " & _
            p.IsClass)
        ' Should be False (because it is an instance)
        Console.WriteLine("IsInstance: " & _
            p.IsInstance)
        ' Should be True
        Console.WriteLine("ClassName: " & _
            p.ClassName)
        ' Should be "Win32_LogicalDisk"
        Console.WriteLine("NamespacePath: " & _
            p.NamespacePath)
        ' Should be "ComputerName\cimv2"
        Console.WriteLine("Server: " & _
            p.Server)
        ' Should be "ComputerName"
        Console.WriteLine("Path: " & _
            p.Path)
        ' Should be "ComputerName\root\cimv2:
        ' Win32_LogicalDisk.DeviceId="C:""
        Console.WriteLine("RelativePath: " & _
            p.RelativePath)
        ' Should be "Win32_LogicalDisk.DeviceID="C:""
    End Function
End Class
	注解
属性值
包含相对路径的字符串 (不包括此 对象中表示) 的服务器和命名空间部分。
.NET Framework 安全性
对直接调用方的完全信任。 此成员不能由部分信任的代码使用。 有关详细信息,请参阅 使用部分受信任的代码中的库。