R
radioworld
Hi All,
I just started playing with C# .NET, experimenting with ASP.NET..
What I want to do is to check if there are certain processes running.
The statement below returns all the processes:
var query = from p in System.Diagnostics.Process.GetProcesses()
select p;
What I am trying to do is to filter only those processnames that have
"firewall".
I noticed that you cannot use something such as LIKE "%firewall%".
There is a Contains() function but that one is case-sensitive..
Although there is a process named "Windows7FirewallService", the query
below doesn't contain nothing :-/
var query = from p in System.Diagnostics.Process.GetProcesses()
where p.ProcessName.Contains("firewall")
select p;
Does anyone have a suggestion on how to alter this code?
Thanks
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication3
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
var query = from p in
System.Diagnostics.Process.GetProcesses()
where p.ProcessName.Contains("firewall")
select p;
// 'Windows7FirewallService' is running, but not showing
up here
foreach (System.Diagnostics.Process p in query)
{
Response.Write(p.ProcessName + "<br/>");
}
}
}
}
I just started playing with C# .NET, experimenting with ASP.NET..
What I want to do is to check if there are certain processes running.
The statement below returns all the processes:
var query = from p in System.Diagnostics.Process.GetProcesses()
select p;
What I am trying to do is to filter only those processnames that have
"firewall".
I noticed that you cannot use something such as LIKE "%firewall%".
There is a Contains() function but that one is case-sensitive..
Although there is a process named "Windows7FirewallService", the query
below doesn't contain nothing :-/
var query = from p in System.Diagnostics.Process.GetProcesses()
where p.ProcessName.Contains("firewall")
select p;
Does anyone have a suggestion on how to alter this code?
Thanks
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication3
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
var query = from p in
System.Diagnostics.Process.GetProcesses()
where p.ProcessName.Contains("firewall")
select p;
// 'Windows7FirewallService' is running, but not showing
up here
foreach (System.Diagnostics.Process p in query)
{
Response.Write(p.ProcessName + "<br/>");
}
}
}
}