How do I find out which process is locking a file using .NET?(如何找出使用 .NET 锁定文件的进程?)
问题描述
我已经看到了几个关于使用 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 锁定文件的进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何找出使用 .NET 锁定文件的进程?


- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 如何用自己压缩一个 IEnumerable 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 输入按键事件处理程序 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01