This documentation is archived and is not being maintained.

EventLog.Exists Method

Determines whether the specified log exists.

Overload List

Determines whether the log exists on the local computer.

[Visual Basic] Overloads Public Shared Function Exists(String) As Boolean
[C#] public static bool Exists(string);
[C++] public: static bool Exists(String*);
[JScript] public static function Exists(String) : Boolean;

Determines whether the log exists on the specified computer.

[Visual Basic] Overloads Public Shared Function Exists(String, String) As Boolean
[C#] public static bool Exists(string, string);
[C++] public: static bool Exists(String*, String*);
[JScript] public static function Exists(String, String) : Boolean;

Example

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of Exists. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Dim myLog As String = "myNewLog"
If EventLog.Exists(myLog) Then
   Console.WriteLine("Log '" + myLog + "' exists.")
Else
   Console.WriteLine("Log '" + myLog + "' does not exist.")
End If

[C#] 
string myLog = "myNewLog";
if (EventLog.Exists(myLog))
{
   Console.WriteLine("Log '"+myLog+"' exists.");
}
else
{
   Console.WriteLine("Log '"+myLog+"' does not exist.");
}

[C++] 
String* myLog = S"myNewLog";
if (EventLog::Exists(myLog)) {
    Console::WriteLine(S"Log '{0}' exists.", myLog);
} else {
    Console::WriteLine(S"Log '{0}' does not exist.", myLog);
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

EventLog Class | EventLog Members | System.Diagnostics Namespace

Show: