如何检测文件是否被访问(打开) [英] How to detect if a file is accessed (Opened)

查看:195
本文介绍了如何检测文件是否被访问(打开)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!


我想创建一个在访问文件时打开的事件(打开)。


我想要什么要做的是监视目录和子目录,如果文件是打开的话。


我试图使用FileSystemWatcher。但它并没有像我预期的那样工作。

我无法在访问文件时触发事件。


任何提示?想法,链接?


问候

马丁

Hi!

I want to create an event that is fiered when a file is accessed (Opened).

What i want to do is monitor a directory and subdirectory if files are
opened.

I have tried to use the FileSystemWatcher. But it didn''t work as i expected.
I cant get it to fire an event when a file is accessed.

Any hints? Ideas, Links?

Regards
Martin

推荐答案

在星期二, 2007年1月23日12:39:45 +0100,Martin Arvidsson,Visual Systems

AB < ma ************** @ vsab.netwrote:
On Tue, 23 Jan 2007 12:39:45 +0100, "Martin Arvidsson, Visual Systems
AB" <ma**************@vsab.netwrote:

>嗨!

我想创建一个在访问(打开)文件时被激活的事件。

我想要做的是监视目录和子目录,如果文件被打开。

我试过使用FileSystemWatcher。但它并没有像我预期的那样工作。
我无法在访问文件时触发事件。

任何提示?想法,链接?

问候
马丁
>Hi!

I want to create an event that is fiered when a file is accessed (Opened).

What i want to do is monitor a directory and subdirectory if files are
opened.

I have tried to use the FileSystemWatcher. But it didn''t work as i expected.
I cant get it to fire an event when a file is accessed.

Any hints? Ideas, Links?

Regards
Martin



它可以完成(至少在Windows中) - 查看工具FileMon来自
www.sysinternals.com 的示例。我怀疑你需要互操作

到Windows API。抱歉,我不能指出你需要哪个API电话

需要。


-

Philip Daniels

It can be done (in Windows at least) - check out the tool FileMon from
www.sysinternals.com for an example. I suspect you will need interop
to the Windows API. Sorry I can''t point you to which API call you will
need.

--
Philip Daniels





您是否尝试过NotifyFilters.LastAccess?


如果还不够好为了你,那么你将不得不p / invoke一些win api

(这应该不是很好)

-

Ignacio Machin < br $>
machin AT laceupsolutions com

" Martin Arvidsson,Visual Systems AB" < ma ************** @ vsab.netwrote在

消息新闻:ut ************** @ TK2MSFTNGP06 .phx.gbl ...

|嗨!

|

|我想创建一个在访问文件时打开的事件(打开)。

|

|我想要做的是监视一个目录和子目录,如果文件是

|打开。

|

|我试过使用FileSystemWatcher。但它没有工作,因为我预计会花费b $ b。

|我无法在访问文件时触发事件。

|

|任何提示?想法,链接?

|

|问候

|马丁

|

|
Hi,

Did you try NotifyFilters.LastAccess ?

If not good enough for you , then you will have to p/invoke some win api
(which should not be nice)
--
Ignacio Machin
machin AT laceupsolutions com
"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netwrote in
message news:ut**************@TK2MSFTNGP06.phx.gbl...
| Hi!
|
| I want to create an event that is fiered when a file is accessed (Opened).
|
| What i want to do is monitor a directory and subdirectory if files are
| opened.
|
| I have tried to use the FileSystemWatcher. But it didn''t work as i
expected.
| I cant get it to fire an event when a file is accessed.
|
| Any hints? Ideas, Links?
|
| Regards
| Martin
|
|


嗨!


是的,但是当我打开文件时没有触发任何事件。


我做错了吗?


问候

Martin


Ignacio Machin(.NET / C#MVP)" < machin TA laceupsolutions.comskrev i

meddelandet新闻:eH ************** @ TK2MSFTNGP05.phx.gbl ...
Hi!

Yes, but no events are triggered when i open the file.

Do i do something wrong?

Regards
Martin

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comskrev i
meddelandet news:eH**************@TK2MSFTNGP05.phx.gbl...




您是否尝试过NotifyFilters.LastAccess?


如果对您不够好,那么你将不得不p / invoke一些win api

(这应该不是很好)


-

Ignacio Machin < br $>
machin AT laceupsolutions com


" Martin Arvidsson,Visual Systems AB" < ma ************** @ vsab.netwrote在

消息新闻:ut ************** @ TK2MSFTNGP06 .phx.gbl ...

|嗨!

|

|我想创建一个在访问文件时被激活的事件

(已打开)。

|

|我想要做的是监视一个目录和子目录,如果文件是

|打开。

|

|我试过使用FileSystemWatcher。但它没有工作,因为我预计会花费b $ b。

|我无法在访问文件时触发事件。

|

|任何提示?想法,链接?

|

|问候

|马丁

|

|

Hi,

Did you try NotifyFilters.LastAccess ?

If not good enough for you , then you will have to p/invoke some win api
(which should not be nice)
--
Ignacio Machin
machin AT laceupsolutions com
"Martin Arvidsson, Visual Systems AB" <ma**************@vsab.netwrote in
message news:ut**************@TK2MSFTNGP06.phx.gbl...
| Hi!
|
| I want to create an event that is fiered when a file is accessed
(Opened).
|
| What i want to do is monitor a directory and subdirectory if files are
| opened.
|
| I have tried to use the FileSystemWatcher. But it didn''t work as i
expected.
| I cant get it to fire an event when a file is accessed.
|
| Any hints? Ideas, Links?
|
| Regards
| Martin
|
|



这篇关于如何检测文件是否被访问(打开)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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