c# 杀死占用某个文件的进程
2024-10-07 07:11:10
需要使用微软提供的工具Handle.exe
string fileName = @"H:\abc.dll";//要检查被那个进程占用的文件 Process tool = new Process();
tool.StartInfo.FileName = @"H:\软件\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+)";
foreach (Match match in Regex.Matches(outputTool, matchPattern))
{
Process.GetProcessById(int.Parse(match.Value)).Kill();
} Console.ReadKey();
最新文章
- Metasploit各版本对比
- CI 框架导出文件
- C# 基础(8)--网络编程
- System类
- 新浪微博客户端(47)-在TextView中插入表情
- NGUI panel使用soft clip时,屏幕缩放后无法正常工作的问题解决
- async:false同步请求,浏览器假死
- 20140704笔试面试总结(java)
- MIP技术进展月报第2期: 数据绑定,异步脚本加速
- React 学习过程中常见的错误
- linux-shell系列4-init
- BZOJ2829信用卡凸包——凸包
- 关闭centos自动升级内核
- BETA随笔6/7
- eclipse调试时增加jvm参数
- Linux上用户之间对话
- 关于两个 IQueryable 合并
- Codeforces Round #364 (Div. 1) 700B(树)
- 处理不同jQuery版本的兼容性问题
- python相关系数