PerformanceCounterCategory.Delete Method

Removes the category and its associated counters from the local computer.

Namespace: System.Diagnostics
Assembly: System (in system.dll)

public static void Delete (
	string categoryName
)
public static void Delete (
	String categoryName
)
public static function Delete (
	categoryName : String
)

Parameters

categoryName

The name of the custom performance counter category to delete.

Exception typeCondition

ArgumentNullException

The categoryName parameter is a null reference (Nothing in Visual Basic).

ArgumentException

The categoryName parameter has invalid syntax. It might contain backslash characters ("\") or have length greater than 80 characters.

Win32Exception

A call to an underlying system API failed.

InvalidOperationException

The category cannot be deleted because it is not a custom category.

You can delete only custom performance counter categories from the system. You cannot delete a counter from a category. To do so, delete the category and recreate the category with the counters you want to retain.

The following code example uses the Delete method to delete a PerformanceCounterCategory and the PerformanceCounter objects that it contains.

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

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

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

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: