确定哪个进程锁定了文件

发布于 2024-07-09 02:03:06 字数 340 浏览 5 评论 0原文

我有一个在本地运行良好的单元测试,但上传到 TeamCity 构建服务器时失败,并显示“该进程无法访问该文件,因为它正在被另一个进程使用。”

  1. 在我在测试中做任何事情之前 我检查设置是否有文件 存在,如果存在尝试删除它。 这会失败并出现相同的错误 消息如上
  2. 当写入时 文件,然后我关闭 writer 我认为应该处理掉它 摆脱任何资源。

所以我有几个疑问

  1. 是否有人遇到过类似的问题并设法解决它们
  2. 如何找出程序化的内容 进程自私地锁定了 文件!!!

干杯

I have a unit test that works fine locally but when uploaded to TeamCity build server fails with "The process cannot access the file because it is being used by another process."

  1. Before I do anything in the Test
    I check in the setup if the file
    exists and if so try to delete it.
    This fails with the same error
    message as above
  2. When wriitng the
    file, I close the writer then
    dispose of it which I believe should
    get rid of any resources.

So I have a couple queries

  1. Has anyone had similar issues and manage to get around them
  2. How can find out programticall what
    process has selfishly locked the
    file!!!

Cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

眼波传意 2024-07-16 02:03:06

Sysinternals handle.exe 是第一步。 或者使用 Process Explorer查找句柄或 DLL。 不过,终止进程总是比关闭句柄更安全。

从编程角度来说,只需编写一个读取 Windows 句柄表的内核驱动程序即可。

Sysinternals handle.exe is the first step. Or use Process Explorer's Find Handle or DLL. It's always safer to kill the process than close the handle, though.

Programmatically, it's a matter of writing a kernel driver that reads the Windows handle table.

故笙诉离歌 2024-07-16 02:03:06

ProcessMon(用于查找)和 Unlocker(至少对于解锁而言)也很有用。

ProcessMon (for finding) and Unlocker (at least for unlocking) are useful too.

皇甫轩 2024-07-16 02:03:06

Sysinternals FileMon 有一些关于他们如何实现这一目标的信息(向下滚动)在旧的 Windows 版本中。

进程监视器是他们的最新版本,但它并没有提供太多关于他们如何做到这一点的线索。 不过,那里链接了一些知识库文章,应该可以引导您找到这些信息。

-亚当

Sysinternals FileMon has some information (scroll down) on how they accomplished this in older windows versions.

Process monitor is their latest version, but it doesn't give many clues as to how they do it. There are some knowledge base articles linked there, though, that should lead you to this information.

-Adam

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文