ManagementPath.NamespacePath Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur bagian namespace dari jalur. Perhatikan bahwa ini tidak termasuk nama server, yang dapat diambil secara terpisah.
public:
property System::String ^ NamespacePath { System::String ^ get(); void set(System::String ^ value); };
public string NamespacePath { get; set; }
member this.NamespacePath : string with get, set
Public Property NamespacePath As String
Nilai Properti
Mengembalikan nilai yang String berisi bagian namespace dari jalur.
Contoh
Contoh berikut menunjukkan bagaimana ManagementPath kelas mengurai jalur ke objek WMI. Jalur yang diurai dalam contoh adalah jalur ke instans kelas.
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
Keterangan
Nilai Properti
String yang berisi bagian namespace dari jalur yang diwakili dalam objek ini.
.NET Framework Security
Kepercayaan penuh untuk penelepon segera. Anggota ini tidak dapat digunakan oleh kode tepercaya sebagian. Untuk informasi selengkapnya, lihat Menggunakan Pustaka dari Kode Tepercaya Sebagian.