ManagementPath 建構函式

定義

初始化 ManagementPath 類別的新執行個體。

多載

ManagementPath()

初始化 ManagementPath 類別的新執行個體,這個執行個體是空白的。 這是無參數建構函式。

ManagementPath(String)

初始化指定路徑的 ManagementPath 類別新執行個體。

ManagementPath()

來源:
ManagementPath.cs
來源:
ManagementPath.cs
來源:
ManagementPath.cs

初始化 ManagementPath 類別的新執行個體,這個執行個體是空白的。 這是無參數建構函式。

public:
 ManagementPath();
public ManagementPath ();
Public Sub New ()

備註

.NET Framework 安全性

完全信任立即呼叫者。 這個成員無法供部分信任的程式碼使用。 如需詳細資訊,請參閱 使用部分信任程式碼的程式庫

適用於

ManagementPath(String)

來源:
ManagementPath.cs
來源:
ManagementPath.cs
來源:
ManagementPath.cs

初始化指定路徑的 ManagementPath 類別新執行個體。

public:
 ManagementPath(System::String ^ path);
public ManagementPath (string path);
new System.Management.ManagementPath : string -> System.Management.ManagementPath
Public Sub New (path As String)

參數

path
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 安全性

完全信任立即呼叫者。 這個成員無法供部分信任的程式碼使用。 如需詳細資訊,請參閱 使用部分信任程式碼的程式庫

適用於