Here i have put the code whats the problem in that code it is not going inside foreach loop
int tempValue = 0;
string f_SearchQuery = "Select * from Win32_NTLogEvent Where Logfile = 'Application' and EventCode = '10'";
ManagementObjectSearcher f_SearchPrintJobs = new
ManagementObjectSearcher(f_SearchQuery);
ManagementObjectCollection f_PrntJobCollection = f_SearchPrintJobs.Get();
foreach (ManagementObject f_PrntJob in f_PrntJobCollection)
{
String m_JobID = f_PrntJob.Properties["Logfile"].Value.ToString();
MessageBox.Show(m_JobID);
// //WriteToFile(m_TotalPages, m_JobID);
// }
// Timer1.Start();
}
MessageBox.Show(tempValue.ToString());
Check the error not going inside foreach loop
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Rajeswari nathan97 reputationPosted Sep 22, 2009, 5:50 AM EDT
Roei BarRank #1,271 · 1.4K reputationPosted Sep 22, 2009, 7:39 AM EDT
MessageBox.Show(f_PrntJobCollection.Count.ToString());
add this before the foreach
i belive that you will see that you have 0 in the collection :-)