Solved

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

Posted on 2006-11-30
6
258 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 500 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 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