ManagementPath.IsInstance Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a value indicating whether this is an instance path.
public:
property bool IsInstance { bool get(); };
public bool IsInstance { get; }
member this.IsInstance : bool
Public ReadOnly Property IsInstance As Boolean
Returns a Boolean value indicating whether this is an instance path.
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:""
}
}
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
true
if this is an instance path; otherwise, false
.
Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
Product | Versions |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
.NET feedback
.NET is an open source project. Select a link to provide feedback: