How can I iterate through a component collection and read the text of each of the compnent?

I'm using vs2005, .net 2.0.  I tried the following code to read the system Securitylog's but am getting error.  padLogEntry is an EventyLogEntry

IEnumerator IEnum = padLogEntry.Container.Components.GetEnumerator();
Error      2      Using the generic type 'System.Collections.Generic.IEnumerator<T>' requires '1' type arguments      C:\Projects\UnityAdmin\EventReport.cs      62
Who is Participating?
rameedevConnect With a Mentor Commented:
if you are interesed in reading a particular evntlog's data you can use some thing like this...

EventLog[] m_EvLogArr = EventLog.GetEventLogs();
                  foreach(EventLog mTmpLog in m_EvLogArr)
                        if(mTmpLog.LogDisplayName=="YourLogName") /// padLogEntry
                              IEnumerator IEnumLog =  mTmpLog.Entries.GetEnumerator();
                              EventLogEntry m_TmpEvLogEntry;
                                    m_TmpEvLogEntry = (EventLogEntry)IEnumLog.Current;      


Try to change:

IEnumerator<Component> IEnum = padLogEntry.Container.Components.GetEnumerator();

lapuccaAuthor Commented:
Hi rameedev,

I need to read the property of the "Security" log's entry.  I think they're stored as components and am wondering how can I read them.  thanks.

Hi anaki, I tried it but it gives an error.

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

You mean to say you want to read msgs in the Security EventLog...Can you clarify?
lapuccaAuthor Commented:
When I double click on an entry of the "Security" log in the system's "Event Viewer", a Property window pops up.  In this window, there is a "Description" section that lists many different information like "User Name:, "Domain", "Login ID"......
How can I obtain each of this inforation in my program?  Thank you.
well the above code which i gave can extract most of the information
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.