473,583 Members | 3,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is file is being used

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.

Dec 12 '06 #1
16 2391
<Er********@gma il.comwrote in message
news:11******** **************@ j72g2000cwa.goo glegroups.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
Dec 12 '06 #2
On 12 Dec 2006 06:03:04 -0800, Er********@gmai l.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
Dec 12 '06 #3

Rad [Visual C# MVP] wrote:
On 12 Dec 2006 06:03:04 -0800, Er********@gmai l.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?

Dec 12 '06 #4

Peter Duniho wrote:
<Er********@gma il.comwrote in message
news:11******** **************@ j72g2000cwa.goo glegroups.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
Hi Pete thanks for the response,
How can i use the exclusive access?
is it a class?

thanks,

Dec 12 '06 #5
On 12 Dec 2006 13:09:57 -0800, Er********@gmai l.com wrote:
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?
Yep. It creates the lock as soon as the database is opened and deletes it
as soon as the database is closed.

Try it and see. Open the mdb in access and then navigate to the folder in
Windows Explorer
--
Bits.Bytes
http://bytes.thinkersroom.com
Dec 12 '06 #6
<Er********@gma il.comwrote in message
news:11******** **************@ j44g2000cwa.goo glegroups.com.. .
Hi Pete thanks for the response,
How can i use the exclusive access?
is it a class?
No...it's simply a part of the parameters you pass when you open the file.
I believe that the default is to open read/write with exclusive access, so
you may not have to specify anything at all. You should check the
documentation to be sure though.
Dec 12 '06 #7
"Rad [Visual C# MVP]" <no****@nospam. comwrote in message
news:kt******** ******@thinkers room.com...
Yep. It creates the lock as soon as the database is opened and deletes it
as soon as the database is closed.
Note that using the presence or content of the .ldb file isn't the right
answer for the original question.

Between the time one looks to see if the .ldb file exists, the status of the
database file could change. Knowing whether the .ldb file exists at time A
tells you nothing about whether you can successfully open the .mdb file at
time B.

If you want to know whether you can successfully open a file exclusively,
the only correct solution is to attempt to open the file exclusively. Any
other method can only provide hints as to whether the operation will succeed
or not, and in particular one will *always* still have to handle the case
where the operation fails even though there's no .ldb file at the time one
checks.

This is a classic issue for a wide variety of computer resources that one
desires to gain exclusive rights to. Whether a file, mutex, i/o port,
whatever...the only reliable means of determining whether one can get access
is to try getting access. Any other method wastes time checking something
that may or may not be valid later when one actually tries to get access.

Pete
Dec 12 '06 #8
On Tue, 12 Dec 2006 14:45:36 -0800, Peter Duniho wrote:
"Rad [Visual C# MVP]" <no****@nospam. comwrote in message
news:kt******** ******@thinkers room.com...
>Yep. It creates the lock as soon as the database is opened and deletes it
as soon as the database is closed.

Note that using the presence or content of the .ldb file isn't the right
answer for the original question.
I beg to differ.

He asked quite explicitly *How can i tell if a file is being used(edited,
open, etc'...)* What you're saying about exclusive use may be true, but is
not what OP asked.

The presence of the lock file is a perfectly valid answer to the question
of whether the file has been opened or not.
--
Bits.Bytes
http://bytes.thinkersroom.com
Dec 12 '06 #9
"Rad [Visual C# MVP]" <no****@nospam. comwrote in message
news:6o******** ******@thinkers room.com...
I beg to differ.

He asked quite explicitly *How can i tell if a file is being used(edited,
open, etc'...)* What you're saying about exclusive use may be true, but is
not what OP asked.

The presence of the lock file is a perfectly valid answer to the question
of whether the file has been opened or not.
Beg to differ all you want. His intent is clear to me. In addition to what
you quoted, he also wrote:

"If the file is not open, then my app can open the file."

and

"I also want this app to have handle to this file"

His application cannot open the file unless it's not already open by someone
else, and the only way to know whether he will be successful in opening the
file is to try doing it. Checking for the presence of a .ldb file tells him
nothing. If the file is absent, the .mdb file could still be unopenable,
and if the file is there, it's still possible that his application could
open the .mdb. The presence of the .ldb doesn't tell him anything about
whether he can actually open the .mdb file or not.

His post is clearly intended to not only find out whether the file has been
opened, but whether HIS application can open it. In any case, even if he
wants to know only whether the .mdb file is open, again...the only way to do
that is to look at that file. There is no way to atomically open one file
and create another simultaneously, and so there is no way a second file can
provide 100% accurate information about the state of another file.

Of course, neither of us will know for sure what his intent is unless he
posts and clarifies. But it's my opinion that his initial post is clear
enough, and he clearly wants access to the .mdb file. Even if he doesn't,
he can't reliably know the state of the .mdb file by looking at something
other than the .mdb file.

Pete
Dec 12 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
9086
by: Dino | last post by:
dear all, i've created an application for a customer where the customer can upload ..csv-files into a specified ftp-directory. on the server, a php-script, triggered by a cronjob, reads all the data, imports it into a mySQL database and deletes the .csv-file after the import. so far, so good. but in some cases the cronjobs starts...
1
2522
by: raydelex | last post by:
I am new to securing a database with logins. My questions is: I want only one database to use a new Workgroup file that I have created, not all the Access databases that I bring up under my system login. Can this be done? Thanks
4
8314
by: Mountain Bikn' Guy | last post by:
I am having serious problems with the following IDE bug: Could not write to output file 'x.dll' -- 'The process cannot access the file because it is being used by another process. ' and BUG: "Could Not Copy Temporary Files to the Output Directory" Error Message When You Build a Solution That Contains Multiple Projects I have tried all...
0
3923
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header,...
5
7842
by: Raj | last post by:
What is the purpose of file system caching while creating a tablespace? Memory on the test server gets used up pretty quickly after a user executes a complex query(database is already activated), after some investgation i found out that most of it being consumed by filesystem caching... thanks to Liam and Phil Sherman for their valuable...
1
6466
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located...
5
4706
by: bulldog8 | last post by:
I've read numerous posts and have tried multiple approaches that I found, but just cannot get a file renamed. I am using VB.Net 2002 ... Here is what I have tried: 1) Code common to all attempts: OldName = "c:\albums\061203\email\DSC07272.JPG" NewName = "c:\albums\061203\email\Lalala.JPG"
8
8853
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
Hi; I copied a new set of files over to my ASP.NET dir (and subdirs) on our test server. This replaced every file for the app. When I first then tried to bring it up, I got the below error. After I bounced IIS, then it worked fine. log4net.dll is in the Bin directory. What is going on here - this makes no sense to me.
0
7894
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8321
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7931
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5699
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5370
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3816
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3841
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1426
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.