string fileName = @"D:\STNI49C002002.hdf";//要检查被那个进程占用的文件

Process tool = new Process();
tool.StartInfo.FileName = @"D:\Google Downloads\Handle\handle64.exe";
tool.StartInfo.Arguments = fileName + " /accepteula";
tool.StartInfo.UseShellExecute = false;
tool.StartInfo.RedirectStandardOutput = true;
tool.Start();
tool.WaitForExit();
string outputTool = tool.StandardOutput.ReadToEnd();
string matchPattern = @"(?<=\s+pid:\s+)\b(\d+)\b(?=\s+)";
MatchCollection matchCollection = Regex.Matches(outputTool, matchPattern);
string fullName = null;
foreach (Match match in matchCollection)
{
    Process process = Process.GetProcessById(int.Parse(match.Value));
    fullName = process.MainModule.FileName;
    process.Kill();
    Console.WriteLine(fullName);
    //D:\MapGIS 10\MapGIS 10\DataStoreService\DS_Service.exe
}
if (fullName == null)
    return;
Thread.Sleep(5000);
try
{
    Process m_Process = new Process();
    m_Process.StartInfo.FileName = fullName;
    bool startProcess = m_Process.Start();
}
catch(Exception err)
{
    Console.WriteLine(err.Message);
}
);
}