Last post Jun 15, 2018 12:50 PM by PatriceSc
Member
504 Points
1776 Posts
Jun 15, 2018 08:42 AM|JagjitSingh|LINK
Hi
I have written below code but it is giving above error
foreach (var process in Process.GetProcessesByName("EXCEL")) { process.Kill(); }
Thanks
All-Star
48280 Points
17983 Posts
Jun 15, 2018 12:50 PM|PatriceSc|LINK
Hi,
Try https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/namespaces/using-namespaces
that is foreach (var process in System.Diagnostics.Process.GetProcessesByName("EXCEL")) should always work.
If you want to use foreach (var process in Process.GetProcessesByName("EXCEL")) you have to use :
using System.Diagnostics;
so that the compiler can search this namespace and figure out your code actually uses "System.Diagnostics.Process"
Member
504 Points
1776 Posts
Error - The name Process does not exists in the current context
Jun 15, 2018 08:42 AM|JagjitSingh|LINK
Hi
I have written below code but it is giving above error
foreach (var process in Process.GetProcessesByName("EXCEL"))
{
process.Kill();
}
Thanks
All-Star
48280 Points
17983 Posts
Re: Error - The name Process does not exists in the current context
Jun 15, 2018 12:50 PM|PatriceSc|LINK
Hi,
Try https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/namespaces/using-namespaces
that is foreach (var process in System.Diagnostics.Process.GetProcessesByName("EXCEL")) should always work.
If you want to use foreach (var process in Process.GetProcessesByName("EXCEL")) you have to use :
using System.Diagnostics;
so that the compiler can search this namespace and figure out your code actually uses "System.Diagnostics.Process"