原文:c# 杀死占用某个文件的进程

需要使用微软提供的工具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();

最新文章

  1. Metasploit各版本对比
  2. CI 框架导出文件
  3. C# 基础(8)--网络编程
  4. System类
  5. 新浪微博客户端(47)-在TextView中插入表情
  6. NGUI panel使用soft clip时,屏幕缩放后无法正常工作的问题解决
  7. async:false同步请求,浏览器假死
  8. 20140704笔试面试总结(java)
  9. MIP技术进展月报第2期: 数据绑定,异步脚本加速
  10. React 学习过程中常见的错误
  11. linux-shell系列4-init
  12. BZOJ2829信用卡凸包——凸包
  13. 关闭centos自动升级内核
  14. BETA随笔6/7
  15. eclipse调试时增加jvm参数
  16. Linux上用户之间对话
  17. 关于两个 IQueryable 合并
  18. Codeforces Round #364 (Div. 1) 700B(树)
  19. 处理不同jQuery版本的兼容性问题
  20. python相关系数

热门文章

  1. MySQL教程-MyISAM和InnoDB的区别
  2. golang rabbitmq实践 (一 rabbitmq配置)
  3. OverFeat:基于卷积网络的集成识别、定位与检测
  4. NABCD分析——生活日历
  5. 【零售App】—— react/ant design mobile项目爬坑
  6. Spring boot 自定义一个starter pom
  7. Python 使用 PyQt5 开发的关机小工具
  8. EasyHook(一)
  9. 无人驾驶车辆路径跟踪的增量式PID控制
  10. 对vi/vim的一些看法