确定谁使用C#的文件打开 [英] Determine who has a file open using C#

查看:113
本文介绍了确定谁使用C#的文件打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用C#我怎样才能得到关于谁打开的文件的信息? 用户名和机器名就足够了。

Using C# how can I get information about who has a file open? User name and machine name would be sufficient.

在情况下,它的问题我在Windows工作站通过Samba Linux文件服务器上访问文件。 我需要在程序信息的工作站上运行。

In case it matters I have Windows workstations accessing files on a Linux file server via Samba. I need this information in a program running on the workstations.

推荐答案

核心.NET库没有任何手段来做到这一点。

The core .NET libraries do not have any means to do this.

如果我理解正确的话,你想知道从谁拥有的文件在Linux文件共享开放,其中一些用户打开的文件可能是来自其他窗口箱始发,如果是这样的话,那么你的Windows工作站A将需要在Linux中,您可以查询到提供回你的Windows工作站的服务。

And if I understand you correctly, you want to know from Windows workstation A who has files open on the Linux file share and some of those users with open file might be origination from other windows boxes, if that is the case then you will need to have a service on the Linux side which you can query to provide that back to your windows work station.

在本地机器可以做到这一点,但最起码​​你需要互操作,以操作系统的API,如的 NtQueryInformationFile NtQueryObject (包括没有正式记录),在其他之中。就像过程监控工具动态地安装设备驱动程序来实现的检查,他们这样做的水平,只会告诉你哪些本地文件句柄是由用户开放。

On the local machine this can be achieved, but at the very least your will need to interop to OS APIs like NtQueryInformationFile and NtQueryObject (both not officially documented) amongst others. Tools like process monitor dynamically install a device driver to achieve the level of inspection that they do and that will only tell you which local file handles are open by which user.

这篇关于确定谁使用C#的文件打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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