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 锁定文件的进程?


基础教程推荐
- 全局 ASAX - 获取服务器名称 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01