Go Premium for a chance to win a PS4. Enter to Win

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
?
280 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
  • 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 feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Screencast - Getting to Know the Pipeline
Suggested Courses

916 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