如何使用 .NET 找出哪个进程正在锁定文件? [英] How do I find out which process is locking a file using .NET?

查看:30
本文介绍了如何使用 .NET 找出哪个进程正在锁定文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过几个关于使用 Handle进程监视器,但我希望能够在我自己的代码 (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.

推荐答案

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 找出哪个进程正在锁定文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆