ManagementPath.Path Property
Definition
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 the string representation of the full path in the object.
public:
property System::String ^ Path { System::String ^ get(); void set(System::String ^ value); };
public string Path { get; set; }
member this.Path : string with get, set
Public Property Path As String
Property Value
Returns a String value containing the full path.
Examples
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
Remarks
Property Value
A string containing the full path represented in this object.
.NET Framework Security
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.
Applies to
Pripomienky
https://aka.ms/ContentUserFeedback.
Pripravujeme: V priebehu roka 2024 postupne zrušíme službu Problémy v službe GitHub ako mechanizmus pripomienok týkajúcich sa obsahu a nahradíme ju novým systémom pripomienok. Ďalšie informácie nájdete na stránke:Odoslať a zobraziť pripomienky pre