问题描述
我已经看到了几个关于使用 Handle 或 a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx" rel="noreferrer">进程监视器,但我希望自己能找到代码 (C#)哪个进程正在锁定文件.
I've seen several of answers about using Handle or Process Monitor, but I would like to be able to find out in my own code (C#) which process is locking a file.
我有一种讨厌的感觉,我将不得不在 win32 API 中进行探索,但如果有人已经这样做并且可以让我走上正确的轨道,我将非常感谢您的帮助.
I have a nasty feeling that I'm going to have to spelunk around in the win32 API, but if anyone has already done this and can put me on the right track, I'd really appreciate the help.
- 如何弄清楚哪个进程使用 c# 锁定了文件?
- 命令行工具
- 跨越一个网络
- 锁定 USB设备
- 单元测试因锁定文件而失败
- 删除锁定文件
推荐答案
handle.exe
的优点之一是您可以将其作为子进程运行并解析输出.
One of the good things about handle.exe
is that you can run it as a subprocess and parse the output.
我们在部署脚本中执行此操作 - 就像一个魅力.
We do this in our deployment script - works like a charm.
这篇关于如何找出使用 .NET 锁定文件的进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!