FileInfo
サイズ/属性/などに基づいてプロセスを終了したい場合..それなら、これは可能です! ここに簡単な例があります
例
int FileSize = 0; //This belongs to the process you would like to terminate
//Create the process csrss for every process with the name csrss
foreach (Process csrss in Process.GetProcessesByName("csrss"))
{
FileInfo csrssFile = new FileInfo(csrss.StartInfo.FileName); //Get the properties of its file name
if (csrssFile.Length == FileSize)
{
csrss.Kill(); //Terminate the process based on its file length (size)
}
}
もう一つの例
int FileSize = 0;
Process[] RunningProcesses = Process.GetProcesses();
foreach (Process csrss in RunningProcesses)
{
if (csrss.ProcessName == "csrss")
{
FileInfo csrssFile = new FileInfo(csrss.StartInfo.FileName);
if (csrssFile.Length == FileSize)
{
csrss.Kill();
}
}
}
ありがとう、
これがお役に立てば幸いです:)