计算文件上的文件句柄 [英] Counting file handles on a file

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

问题描述

大家好,


我正在等待收到目录中的文件。我使用

FileSystemWatcher来检测文件到达所述文件夹的时间。我需要

尽快从这些文件中读取数据但是文件已经创建并且在写入完成之前检测到了
因此我无法读取它们直到
$ b在他们的创作中使用的$ b文件句柄已经发布。


这可以很容易地解决文件重命名或其他文件

锁定机制我可以使用除了我没有控制

的文件drop因为他们来自第三方,而不是改变。我只是看到文件到了。


所以,简而言之,我如何确定文件上的文件句柄数

以便当一个文件到达时我可以等到它被释放了吗?


谢谢,

康拉德

Hello all,

I am waiting for receipt of files in a directory. I use the
FileSystemWatcher to detect when files arrive in said folder. I need
to read the data from these files ASAP but the files are created and
detected before writing completes and so I cannot read them until the
file handle used in their creation has been released.

This would be easy to get around with file renaming or other file
locking mechanisms which I could use except that I have no control
over the file "drops" because they are from a 3rd party and not about
to change. I simply see the files arrive.

So, in brief, how can I determine the number of file handles on a file
so that when one arrives I can wait until it is released?

Thanks,
Conrad

推荐答案



" Conrad F" <共********* @ hotmail.com>在消息中写道

news:6a ************************** @ posting.google.c om ...

"Conrad F" <co*********@hotmail.com> wrote in message
news:6a**************************@posting.google.c om...
大家好,

我在等待收到目录中的文件。我使用
FileSystemWatcher来检测文件到达所述文件夹的时间。我需要尽快从这些文件中读取数据但是在写入完成之前创建并检测文件,因此在创建中使用的
文件句柄被释放之前我无法读取它们。

这很容易解决文件重命名或其他文件锁定机制,我可以使用除了我无法控制文件drop之外。因为他们来自第三方而不是改变。我只是看到文件到了。

因此,简而言之,我如何确定文件上的文件句柄数量
以便当一个文件到达时我可以等到它被释放? br />
谢谢,
康拉德
Hello all,

I am waiting for receipt of files in a directory. I use the
FileSystemWatcher to detect when files arrive in said folder. I need
to read the data from these files ASAP but the files are created and
detected before writing completes and so I cannot read them until the
file handle used in their creation has been released.

This would be easy to get around with file renaming or other file
locking mechanisms which I could use except that I have no control
over the file "drops" because they are from a 3rd party and not about
to change. I simply see the files arrive.

So, in brief, how can I determine the number of file handles on a file
so that when one arrives I can wait until it is released?

Thanks,
Conrad




你不能触摸文件,只要它不被写入并完全关闭,

因此你也无法获得文件句柄,你唯一能做的就是在试图打开文件的循环中等待
。 />

Willy。



You can''t touch the file as long as it isn''t written and closed completely,
so you can''t get at the file handles too, the only thing you can do is wait
in a loop that tries to open the file.

Willy.


不确定这是否适用于您的问题,或者即使它在.net中是相同的。

我们有一个类似于你想要的东西的过程,我们注意到的是b $ b注意到文件大小为0,直到文件完全为止

写的。您可以查看是否获得文件列表显示这一点

也适用于您。


在我们的方案中,文件总是少于然后是1k,总是由IIS编写,

我们使用win32 API中的FindFirst / FindNext来检查文件。


-

谢谢

Wayne Sepega

杰克逊维尔,佛罗里达

当一个男人和一个漂亮女孩坐在一起一小时后,它似乎是一个分钟。但是

让他坐在热炉上一分钟,它比任何一小时都要长。

那是'相对论'。 - 阿尔伯特爱因斯坦


"康拉德F" <共********* @ hotmail.com>在消息中写道

news:6a ************************** @ posting.google.c om ...
Not sure if this will work for your issue or even if it is the same in .net.
We have a process that does something similar to what you want, what we
noticed is that the file size remained 0 until the file had been completely
written. You may check to see if getting a list of the files shows this to
be true for you as well.

In our scenario the files are always less then 1k, always written by IIS and
we used the FindFirst/FindNext in win32 API to check for files.

--
Thanks
Wayne Sepega
Jacksonville, Fl
"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it''s longer than any hour.
That''s relativity." - Albert Einstein

"Conrad F" <co*********@hotmail.com> wrote in message
news:6a**************************@posting.google.c om...
大家好,

我在等待收到目录中的文件。我使用
FileSystemWatcher来检测文件到达所述文件夹的时间。我需要尽快从这些文件中读取数据但是在写入完成之前创建并检测文件,因此在创建中使用的
文件句柄被释放之前我无法读取它们。

这很容易解决文件重命名或其他文件锁定机制,我可以使用除了我无法控制文件drop之外。因为他们来自第三方而不是改变。我只是看到文件到了。

因此,简而言之,我如何确定文件上的文件句柄数量
以便当一个文件到达时我可以等到它被释放? br />
谢谢,
康拉德
Hello all,

I am waiting for receipt of files in a directory. I use the
FileSystemWatcher to detect when files arrive in said folder. I need
to read the data from these files ASAP but the files are created and
detected before writing completes and so I cannot read them until the
file handle used in their creation has been released.

This would be easy to get around with file renaming or other file
locking mechanisms which I could use except that I have no control
over the file "drops" because they are from a 3rd party and not about
to change. I simply see the files arrive.

So, in brief, how can I determine the number of file handles on a file
so that when one arrives I can wait until it is released?

Thanks,
Conrad





我很感兴趣你的主题并做了一些研究,

我刚发现 http://www.sysinternals.com/ntw2k/source/filemon.shtml

..这是一个文件moniotr应用程序,在那个页面你可以找到

"在Windows NT上,FileMon的核心是一个文件系统驱动程序,它创建并且

将过滤器设备对象附加到目标文件系统设备对象,以便

FileMon将查看针对驱动器的所有IRP和FastIO请求。当

FileMon看到一个打开,创建或关闭调用时,它会更新一个内部哈希表,用作内部文件句柄和文件路径之间的映射

名字。


所以我继续使用谷歌搜索,发现你可能需要做一些

驱动程序开发,即文件系统过滤器驱动程序。我认为通过

这些你当然可以得到你想知道的所有I / O操作,

这是我的能力之外的。


如果有人有个好主意,请告诉我。

祝你好运。

Daiyue


Willy Denoyette [MVP]" <无线************* @ pandora.be> D'è????¢D ???: ex***************@TK2MSFTNGP15.phx.gb l ...
Hi,
I''m quite interested in your topic and do a little research,
I just found http://www.sysinternals.com/ntw2k/source/filemon.shtml
..That is a file moniotr application,at that page you can find
"On Windows NT the heart of FileMon is a file system driver that creates and
attaches filter device objects to target file system device objects so that
FileMon will see all IRPs and FastIO requests directed at drives. When
FileMon sees an open, create or close call, it updates an internal hash
table that serves as the mapping between internal file handles and file path
names. "

So I go on googling and find that maybe you need to do some kind of
driver development,which is "File System Filter Drivers".I think by
those way you can certainly get all the I/O operation you want to know,
which is out of my capability.

If anyone got a good idea,please let me know.
Good luck.
Daiyue

"Willy Denoyette [MVP]" <wi*************@pandora.be> D′è????¢D???:ex***************@TK2MSFTNGP15.phx.gb l...

康拉德F <共********* @ hotmail.com>在消息中写道
新闻:6a ************************** @ posting.google.c om ...

"Conrad F" <co*********@hotmail.com> wrote in message
news:6a**************************@posting.google.c om...
大家好,

我正在等待收到目录中的文件。我使用
FileSystemWatcher来检测文件到达所述文件夹的时间。我需要尽快从这些文件中读取数据但是在写入完成之前创建并检测文件,因此在创建中使用的
文件句柄被释放之前我无法读取它们。

这很容易解决文件重命名或其他文件锁定机制,我可以使用除了我无法控制文件drop之外。因为他们来自第三方而不是改变。我只是看到文件到了。

因此,简而言之,我如何确定文件上的文件句柄数量
以便当一个文件到达时我可以等到它被释放? br />
谢谢,
康拉德
Hello all,

I am waiting for receipt of files in a directory. I use the
FileSystemWatcher to detect when files arrive in said folder. I need
to read the data from these files ASAP but the files are created and
detected before writing completes and so I cannot read them until the
file handle used in their creation has been released.

This would be easy to get around with file renaming or other file
locking mechanisms which I could use except that I have no control
over the file "drops" because they are from a 3rd party and not about
to change. I simply see the files arrive.

So, in brief, how can I determine the number of file handles on a file
so that when one arrives I can wait until it is released?

Thanks,
Conrad



只要它没有被写入和关闭,你就不能触摸文件
,所以你也无法获得文件句柄,你唯一可以做的就是等待一个试图打开文件的循环。

威利。



You can''t touch the file as long as it isn''t written and closed
completely, so you can''t get at the file handles too, the only thing you
can do is wait in a loop that tries to open the file.

Willy.



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

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