Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-11-30
6
Medium Priority
?
270 Views
Last Modified: 2010-04-16
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
0
Comment
Question by:lapucca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 18051162
Try to change:

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

0
 
LVL 5

Accepted Solution

by:
rameedev earned 2000 total points
ID: 18051861
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;
                              while(IEnumLog.MoveNext())
                              {
                                    m_TmpEvLogEntry = (EventLogEntry)IEnumLog.Current;      

                                    Console.WriteLine(m_TmpEvLogEntry.MachineName);
                                    Console.WriteLine(m_TmpEvLogEntry.Category);
                                    Console.WriteLine(m_TmpEvLogEntry.EntryType.ToString());
                                    Console.WriteLine(m_TmpEvLogEntry.TimeWritten.ToLongDateString());
                                    Console.WriteLine(m_TmpEvLogEntry.UserName);
                                    Console.WriteLine(m_TmpEvLogEntry.Message);
                              }
                        }
                  }

0
 

Author Comment

by:lapucca
ID: 18057477
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.


Thanks.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Expert Comment

by:rameedev
ID: 18066411
You mean to say you want to read msgs in the Security EventLog...Can you clarify?
0
 

Author Comment

by:lapucca
ID: 18066533
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.
0
 
LVL 5

Expert Comment

by:rameedev
ID: 18066562
well the above code which i gave you...you can extract most of the information
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question