1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 using System.Diagnostics; 7 8 9 namespace ConsoleApplication1 10 { 11 class Program 12 { 13 static void Main(string[] args) 14 { 15 EventLog log = new EventLog(); 16 try 17 { 18 log.Source = "系統2"; 19 log.WriteEntry("deal with message of one", EventLogEntryType.Information); 20 log.WriteEntry("deal with message of two",EventLogEntryType.Information); 21 throw new System.IO.FileNotFoundException("readme.txt文件未找到"); 22 } 23 catch(System.IO.FileNotFoundException exception) 24 { 25 log.WriteEntry("deal with message two",EventLogEntryType.Error); 26 } 27 28 } 29 } 30 }