Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

ManagementPath Class

Provides a wrapper for parsing and building paths to WMI objects.

System.Object
  System.Management.ManagementPath

Namespace:  System.Management
Assembly:  System.Management (in System.Management.dll)
public class ManagementPath : ICloneable

The ManagementPath type exposes the following members.

  NameDescription
Public methodManagementPath()Initializes a new instance of the ManagementPath class that is empty. This is the default constructor.
Public methodManagementPath(String)Initializes a new instance of the ManagementPath class for the given path.
Top
  NameDescription
Public propertyClassNameGets or sets the class portion of the path.
Public propertyStatic memberDefaultPathGets or sets the default scope path used when no scope is specified. The default scope is \\.\root\cimv2, and can be changed by setting this property.
Public propertyIsClassGets or sets a value indicating whether this is a class path.
Public propertyIsInstanceGets or sets a value indicating whether this is an instance path.
Public propertyIsSingletonGets or sets a value indicating whether this is a singleton instance path.
Public propertyNamespacePathGets or sets the namespace part of the path. Note that this does not include the server name, which can be retrieved separately.
Public propertyPathGets or sets the string representation of the full path in the object.
Public propertyRelativePathGets or sets the relative path: class name and keys only.
Public propertyServerGets or sets the server part of the path.
Top
  NameDescription
Public methodCloneReturns a copy of the ManagementPath.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSetAsClassSets the path as a new class path. This means that the path must have a class name but not key values.
Public methodSetAsSingletonSets the path as a new singleton object path. This means that it is a path to an instance but there are no key values.
Public methodToStringReturns the full object path as the string representation. (Overrides Object.ToString().)
Top
  NameDescription
Explicit interface implemetationPrivate methodICloneable.CloneCreates a new object that is a copy of the current instance.
Top

The following example demonstrates how the ManagementPath class parses a path to a WMI object. The path that is parsed in the example is a path to an instance of a class.

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:""

    }
}

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.