Removes the registration for an event source if it has been registered : Event Log « Windows « C# / C Sharp






Removes the registration for an event source if it has been registered

/*
C# Programming Tips & Techniques
by Charles Wright, Kris Jamsa

Publisher: Osborne/McGraw-Hill (December 28, 2001)
ISBN: 0072193794
*/

// RemSrc.cs -- Removes the registration for an event source if
//              it has been registered.
//
//              Compile this program with the following command line:
//                  C:>csc RemSrc.cs
using System;
using System.Diagnostics;

namespace nsEventLogs
{
    public class RemSrc
    {
        static public void Main (string [] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine ("Please enter an event source to remove.");
                Console.WriteLine ("Usage: RemSrc [source]");
                return;
            }
            if (EventLog.SourceExists (args[0]))
            {
                Console.WriteLine ("Deleting event log source " + args[0]);
                EventLog.DeleteEventSource (args[0]);
            }
        }
    }
}


           
       








Related examples in the same category

1.Check Event Source Existance and Create Event Source
2.Write Message to system event logWrite Message to system event log
3.Get first 5 message from system event log
4.Write the Event Log Entry type as Information
5.Specify EventLogEntryType