Saturday, February 13, 2010

HOW TO KILL PROCESS IN FINALLY BLOCK

catch (Exception ex)
{

}
finally
{
System.Diagnostics.Process[] prs = System.Diagnostics.Process.GetProcesses();

foreach (System.Diagnostics.Process proces in prs)
{

if (proces.ProcessName.ToUpper() == "EXCEL")
{
proces.Refresh();
if (!proces.HasExited)
proces.Kill();
}
}
}
}

No comments:

Post a Comment