是否正在使用文件 [英] Is file is being used

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

问题描述




我在局域网中共享了一个mdb文件。我想写一个验证

的应用程序如果它打开了。

如果文件没有打开,那么我的应用程序可以打开文件。

如果使用该文件,那么应用程序就不会打开它。


我也希望这个应用程序能够处理这个文件,然后当用户

停止编辑此文件,他可以使用此应用关闭它。


所以我的问题是:


1.如何我可以判断一个文件是否被使用(编辑,打开等等'...)

2.如何关闭文件(并保存数据)?

TIA。

解决方案

< Er ******** @ gmail.comwrote in message

新闻:11 ********************** @ j72g2000cwa.googlegr oups.com ...


1.如何判断文件是否正在使用(编辑,打开等等'...)



试试以独家访问权限打开它。如果你成功了,它就没有被使用。


2.我如何关闭文件(并保存数据)?



数据被保存当你写入文件时,虽然不一定是确切的

时刻。您可以在各种文件i / o

类上使用Close方法,以确保文件实际关闭,缓冲区已经完全刷新了




Pete


2006年12月12日06:03:04 -0800, Er ******** @ gmail.com 写道:





我在局域网中共享一个mdb文件。我想写一个验证

的应用程序如果它打开了。

如果文件没有打开,那么我的应用程序可以打开文件。

如果使用该文件,那么应用程序就不会打开它。


我也希望这个应用程序能够处理这个文件,然后当用户

停止编辑此文件,他可以使用此应用关闭它。


所以我的问题是:


1.如何我可以判断一个文件是否被使用(编辑,打开等等'...)

2.如何关闭文件(并保存数据)?

TIA。



如果我没错,MDB在打开时会生成一个临时锁定文件,

具有相同的名称但扩展名.LDB。您可以尝试检查该文件是否存在以确定其是否已打开


至于从其他应用程序关闭它 - 不确定该< br $>
-

Bits.Bytes
http://bytes.thinkersroom.com




Rad [Visual C#MVP]写道:


2006年12月12日06:03:04 -0800, Er ***** ***@gmail.com 写道:





我有一个共享的mdb文件局域网。我想写一个验证

的应用程序如果它打开了。

如果文件没有打开,那么我的应用程序可以打开文件。

如果使用该文件,那么应用程序就不会打开它。


我也希望这个应用程序能够处理这个文件,然后当用户

停止编辑此文件,他可以使用此应用关闭它。


所以我的问题是:


1.如何我可以判断一个文件是否被使用(编辑,打开等等'...)

2.如何关闭文件(并保存数据)?

TIA。



如果我没错,MDB在打开时会生成一个临时锁定文件,

同名,但扩展名.LDB。您可以尝试检查该文件是否存在以确定其是否已打开


至于从其他应用程序关闭它 - 不确定该< br $>
-

Bits.Bytes
http://bytes.thinkersroom.com



哦,伙计,谢谢。

现在我知道ldb是什么意思了。锁定数据库。

谢谢,如果我的ldb文件中包含使用该文件的用户使用该文件的任何信息,并且我可以解析该文件,那么我是否更胜一筹。 br />

当mdb文件停止使用时,是否删除了ldb文件
使用了


是否正在创建ldb文件一旦其他人打开

文件?


也许我应该在WinAPI新闻组中得到回应?


Hi,

I have a mdb file shared in the LAN. I want to write app that verifies
if it''s open.
If the file is not open, then my app can open the file.
if the file is used, then the app won''t open it.

I also want this app to have handle to this file, then when the user
stops editting this file, he can close it using this app.

so my questions are:

1. How can i tell if a file is being used(edited, open, etc''...)
2. How can i close file(and save the data)?

TIA.

解决方案

<Er********@gmail.comwrote in message
news:11**********************@j72g2000cwa.googlegr oups.com...

1. How can i tell if a file is being used(edited, open, etc''...)

Try to open it with exclusive access. If you succeed, it''s not being used.

2. How can i close file(and save the data)?

Data is "saved" as you write to the file, though not necessarily the exact
moment you do so. You can use the Close method on the various file i/o
classes to ensure that the file is actually closed and the buffers have been
completely flushed.

Pete


On 12 Dec 2006 06:03:04 -0800, Er********@gmail.com wrote:

Hi,

I have a mdb file shared in the LAN. I want to write app that verifies
if it''s open.
If the file is not open, then my app can open the file.
if the file is used, then the app won''t open it.

I also want this app to have handle to this file, then when the user
stops editting this file, he can close it using this app.

so my questions are:

1. How can i tell if a file is being used(edited, open, etc''...)
2. How can i close file(and save the data)?

TIA.

If I''m not wrong a MDB generates a temporary lock file when it is open,
with the same name but the extension .LDB. You can try checking for the
existence of that file to know if its is open

As for closing it from another application -- not sure about that
--
Bits.Bytes
http://bytes.thinkersroom.com



Rad [Visual C# MVP] wrote:

On 12 Dec 2006 06:03:04 -0800, Er********@gmail.com wrote:

Hi,

I have a mdb file shared in the LAN. I want to write app that verifies
if it''s open.
If the file is not open, then my app can open the file.
if the file is used, then the app won''t open it.

I also want this app to have handle to this file, then when the user
stops editting this file, he can close it using this app.

so my questions are:

1. How can i tell if a file is being used(edited, open, etc''...)
2. How can i close file(and save the data)?

TIA.


If I''m not wrong a MDB generates a temporary lock file when it is open,
with the same name but the extension .LDB. You can try checking for the
existence of that file to know if its is open

As for closing it from another application -- not sure about that
--
Bits.Bytes
http://bytes.thinkersroom.com

Oh man, thanks.
Now I know what''s that ldb mean. Lock data base.
thanks, i wounder if i ldb file holds any information on the user who''s
using the file and if i can parse the file.

does the ldb file is being deleted when the mdb file is stopped being
used?
does the ldb file is being created as soon as someone else opens the
file?

Maybe i should get response to this in WinAPI news group?


这篇关于是否正在使用文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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