打开文件和锁 [英] Open files and locks

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

问题描述

在dotnet中有没有办法确定哪些文件有锁,然后

什么进程锁定文件?

Is there a way in the dotnet to determine what files have locks and then
what process is locking the file?

推荐答案

我担心你必须调用ntdll.dll来获得你想要的东西。


Yves


标记 <无************ @ technologist.com> schreef in bericht

新闻:%2 **************** @ TK2MSFTNGP12.phx.gbl ...
I''m afraid you''ll have to p/invoke ntdll.dll to get what you want.

Yves

"Mark" <no************@technologist.com> schreef in bericht
news:%2****************@TK2MSFTNGP12.phx.gbl...
是否有在dotnet中确定哪些文件有锁定然后
锁定文件的过程是什么?
Is there a way in the dotnet to determine what files have locks and then
what process is locking the file?




嗨Mark,


感谢您在社区发帖!


根据我的理解,您想确定是否一个文件被

另一个进程锁定,哪个进程锁定了这个文件。


=============== ==============================

对于您的第一部分问题,您可以使用例外来获取这样做:

使用.Net应用程序访问此文件,如果此文件被锁定,那么将在异常处理程序中生成异常将生成异常,您可以确定

此文件被另一个进程锁定。


对于您的第二部分问题,.Net没有为用户公开此功能。

实际上,事件在win32环境中,没有记录的方法来获取这些信息



您可以使用一些未记录的Windows 2000 / NT本机API来完成此任务。

这些API包含在ntdll.dll中。

在.Net中,你可以使用P / invoke来使用它们。


更多信息,请参阅:
http://groups.google.com/groups?hl=e...ame=right&th=d

392ffdb818c5665& seekm = vL7bp2axCHA.3256%40cpmsftngx a06#link1


此外,下面的文章Inside the Native API可能会给你更多关于原生api的信息:
http://www.sysinternals.com/ntw2k/info/ntdll.shtml

有一个Process Explorer在sysinternals网站上的工具,它可能会对你有所帮助,请参考:
http://www.sysinternals.com/ntw2k/fr.../procexp.shtml


==== =======================================

请申请我的上面的建议,让我知道它是否有助于解决您的问题。


感谢您的耐心和合作。如果您有任何疑问或

担忧,请随时将其发布在小组中。我正准备等待

的帮助。

祝你有美好的一天!!


祝你好运,

Jeffrey Tan

Microsoft在线合作伙伴支持

安全! - www.microsoft.com/security

此帖子按原样提供没有保证,也没有授予任何权利。


Hi Mark,

Thank you for posting in the community!

Based on my understanding, you want to determine if one file is locked by
another process, and which process locked this file.

=============================================
For your first part concern, you can use exception to get this done:
Use you .Net application to access this file, if this file is locked, then
an exception will generate, in the exception handler, you can determine
that this file is locked by another process.

For your second part concern, .Net did not expose this function for users.
Actually, event in win32 environment, there are not a documented way to get
this information.
You may use some undocumented Windows 2000/NT native API to get this done.
These APIs are included in ntdll.dll.
In .Net, you can use P/invoke to use them.

For more information, please refer to:
http://groups.google.com/groups?hl=e...ame=right&th=d
392ffdb818c5665&seekm=vL7bp2axCHA.3256%40cpmsftngx a06#link1

Also, the below article "Inside the Native API" may give you more
information on native api:
http://www.sysinternals.com/ntw2k/info/ntdll.shtml

There is a "Process Explorer" tool in sysinternals website, it may help
you, please refer to:
http://www.sysinternals.com/ntw2k/fr.../procexp.shtml

===========================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.




嗨Mark,


我的回复对您有意义吗?


如果您仍有任何疑虑,请随时提供反馈意见,我会帮助您支付



祝你好运,

Jeffrey Tan

微软在线合作伙伴支持

安全! - www.microsoft.com/security

此帖子按原样提供没有保证,也没有赋予任何权利。


Hi Mark,

Does my reply make sense to you?

If you still have any concern, please feel free to feedback, I will help
you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


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

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