Hi, I use code shown below to get application name, but it shows "No "result" or "error" in XML response."
Process[] processlist = Process.GetProcesses(); Console.WriteLine(@"<?xml version=""1.0"" encoding=""UTF-8"" ?>"); Console.WriteLine(@"<prtg>"); foreach (Process process in processlist) { if (!String.IsNullOrEmpty(process.MainWindowTitle)) { Console.WriteLine(" " + @"<result>"); Console.WriteLine(" " + @"<channel>" + process.MainWindowTitle + "</channel>"); Console.WriteLine(" " + @"<unit>" + "Custom" + "</unit>"); Console.WriteLine(" " + @"<value>" + "0" + "</value>"); Console.WriteLine(" " + @"</result>"); } } Console.WriteLine(" </prtg>"); and i found a phenomenon, when i remove the for loop then hard code shown below, it Works!!! Process[] processlist = Process.GetProcesses(); Console.WriteLine(@"<?xml version=""1.0"" encoding=""UTF-8"" ?>"); Console.WriteLine(@"<prtg>"); Console.WriteLine(" " + @"<result>"); Console.WriteLine(" " + @"<channel>" + "process.MainWindowTitle" + "</channel>"); Console.WriteLine(" " + @"<unit>" + "Custom" + "</unit>"); Console.WriteLine(" " + @"<value>" + "0" + "</value>"); Console.WriteLine(" " + @"</result>"); Console.WriteLine(" " + @"<result>"); Console.WriteLine(" " + @"<channel>" + "process.MainWindowTitle" + "</channel>"); Console.WriteLine(" " + @"<unit>" + "Custom" + "</unit>"); Console.WriteLine(" " + @"<value>" + "0" + "</value>"); Console.WriteLine(" " + @"</result>"); Console.WriteLine(" </prtg>");
Could u help me to solve the problem ? Thanks.
Add comment