检测文件打开
在 Windows 环境中是否可以检测是否正在使用 .NET 打开文件
我想在文件系统上放置一个处理程序来检测是否正在打开一个文件或任何文件,这可能吗?
Is it possible in the Windows environment to detect if a file is being opened with with .NET
I would like to place a handler on the file system to detect if a file or any file is being opened, is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
最简单的解决方案是使用
FileSystemWatcher
并将过滤器设置为
NotifyFilters.LastAccess
,这将告诉它监视上次访问日期/时间的更改。The simplest solution would be to use a
FileSystemWatcher
and set the filter toNotifyFilters.LastAccess
, which will tell it to watch for a change in the last access date/time.查看 FileSystemWatcher 类
http://msdn.microsoft.com /en-us/library/system.io.filesystemwatcher.aspx
我不能 100% 确定您可以确定文件是否被打开,但您可以确定文件是否被更改、创建、删除。
Check out the FileSystemWatcher class
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx
I'm not 100% sure that you can determine if a file is opened, but you can determine if a file is changed, created, deleted.
不久前,我需要一个应用程序来监视特定文件夹(及其子文件夹)并在创建新文件时引发事件。 我使用了 FileWatcher 类。 我很确定它的事件“更改”会对您有用。 它很好并且易于实现。 检查下面的站点以获取更多信息:
usethisaddress msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx
usethisaddres csharphelp.com/archives2/archive377.html
希望这会有所帮助。
达摩
Some time ago I needed an app to monitor particular folder (and its subfolders) and raise an event if there was a new file created. I used FileWatcher Class. I'm pretty sure that its event 'changed' would work for you. It's nice and simple to implement. Check the sitets below for more info:
usethisaddress msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx
usethisaddres csharphelp.com/archives2/archive377.html
Hope this helps.
Damo
System.IO.FileSystemWatcher 可能就是您的内容正在寻找。
AFAIK 无法检测文件是否是使用 .NET 或其他方式打开的。
System.IO.FileSystemWatcher may be what you're looking for.
AFAIK there is no way to detect if a file was opened with .NET or otherwise.