PerformanceCounterCategory.Delete 方法

从本地计算机移除类别及其关联的计数器。

**命名空间:**System.Diagnostics
**程序集:**System(在 system.dll 中)

语法

声明
Public Shared Sub Delete ( _
    categoryName As String _
)
用法
Dim categoryName As String

PerformanceCounterCategory.Delete(categoryName)
public static void Delete (
    string categoryName
)
public:
static void Delete (
    String^ categoryName
)
public static void Delete (
    String categoryName
)
public static function Delete (
    categoryName : String
)

参数

  • categoryName
    要删除的自定义性能计数器类别的名称。

异常

异常类型 条件

ArgumentNullException

categoryName 参数为 空引用(在 Visual Basic 中为 Nothing)。

ArgumentException

categoryName 参数的语法无效。它可能包含反斜杠字符 ("\") 或者长度大于 80 个字符。

Win32Exception

对基础系统 API 的调用失败。

InvalidOperationException

不能删除该类别,因为它不是自定义类别。

备注

只能从系统中删除自定义性能计数器类别。不能从类别中删除计数器。若要这样做,请删除该类别,然后重新创建类别,使之拥有您要保留的计数器。

示例

下面的代码示例使用 Delete 方法删除 PerformanceCounterCategory 及其包含的 PerformanceCounter 对象。

Sub Main(ByVal args() As String)
    Dim categoryName As String = ""

    ' Copy the supplied argument into the local variable.
    Try
        categoryName = args(0)
    Catch ex As Exception
    End Try

    ' Delete the specified category.
    Try
        PerformanceCounterCategory.Delete(categoryName)
        Console.WriteLine( _
            "Category ""{0}"" deleted from this computer.", categoryName)

    Catch ex As Exception
        Console.WriteLine("Unable to delete " & _
            "category ""{0}"" from this computer:" & vbCrLf & _
            ex.Message, categoryName)
    End Try
End Sub

.NET Framework 安全性

平台

Windows 98、Windows 2000 SP4、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

PerformanceCounterCategory 类
PerformanceCounterCategory 成员
System.Diagnostics 命名空间
Create