Solved

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

Posted on 2006-11-30
6
243 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 29

Expert Comment

by:anarki_jimbel
Comment Utility
Try to change:

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

0
 
LVL 5

Accepted Solution

by:
rameedev earned 500 total points
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 5

Expert Comment

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

Author Comment

by:lapucca
Comment Utility
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
Comment Utility
well the above code which i gave you...you can extract most of the information
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now