472,989 Members | 2,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,989 software developers and data experts.

Detecting File State

I'm looking for a way to detect if another process has a file open before a
second process tries to open it. I've looked into the FileAttr function but
I'm not sure if detecting a read-only state is sufficient. Can anyone
confirm or deny? TIA...
Nov 21 '05 #1
7 1387
> I'm looking for a way to detect if another process has a file open before
a

Make certain you know it exists, then,
Try to open the file exclusively,
an error means it is in use.
Good day,
Roger
Nov 21 '05 #2
"Roger" <ro***@pcsrevenuecontrol.com> wrote:
I'm looking for a way to detect if another process has a file open
before a


Make certain you know it exists, then,
Try to open the file exclusively,
an error means it is in use.


I'm not proposing a better solution, but I'm pretty sure using error-
trapping or exception handling to test for a thoroughly possible condition
like this would not qualify as a "best practice"...

--
Michael Kellogg
Nov 21 '05 #3
Glen,

This is endless asked, however this is as long as there are the MS-dos
operating systems and its successors not possible when you don't create a
special management tool around it, as probably in Office is done.

Cor
Nov 21 '05 #4
I have to agree. I'm thinking there must be a way to test the state of the
file for this condition. I just haven't found anything yet...

"Michael Kellogg" <mk******@WEDELIVERcc3.com> wrote in message
news:Xn**********************************@207.46.2 48.16...
"Roger" <ro***@pcsrevenuecontrol.com> wrote:
I'm looking for a way to detect if another process has a file open
before a


Make certain you know it exists, then,
Try to open the file exclusively,
an error means it is in use.


I'm not proposing a better solution, but I'm pretty sure using error-
trapping or exception handling to test for a thoroughly possible condition
like this would not qualify as a "best practice"...

--
Michael Kellogg

Nov 21 '05 #5
It's 'The eternal question', then...

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uO**************@TK2MSFTNGP15.phx.gbl...
Glen,

This is endless asked, however this is as long as there are the MS-dos
operating systems and its successors not possible when you don't create a
special management tool around it, as probably in Office is done.

Cor

Nov 21 '05 #6
glen,

Answers on this are

do while loop condition = false
Try
Open a file
When found leave set the condition to true
Catch
threading.thread.sleep(1000)
'And set a max if you want
End

I hope this helps something

Cor
Nov 21 '05 #7
Interesting....I'll try that. Thanks.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uf**************@tk2msftngp13.phx.gbl...
glen,

Answers on this are

do while loop condition = false
Try
Open a file
When found leave set the condition to true
Catch
threading.thread.sleep(1000)
'And set a max if you want
End

I hope this helps something

Cor

Nov 21 '05 #8

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

Similar topics

5
by: Jole | last post by:
Hi I'm writing a program that needs to read from a file. In order for the program to be robust, it should somehow check that the file isn't corrupt, or stuffed in any way. For example, that...
7
by: fox | last post by:
Maybe this is not the best group to ask this question, but I don't know a better one. I'm looking for a *portable* program in C (I mean source code) to detect whether unaligned word access is:...
2
by: Anthony | last post by:
In C++ you can detect the screensaver state by using something like: BOOL b=SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, NULL, &bOn, FALSE); Is there an equivalent method that I can use in...
6
by: Andrea | last post by:
I need to detect when another application is launched. I'd need to know also when a new folder is opened in explorer. I'm developing an application to speed up access to frequently used...
0
by: Adrian Bezzina | last post by:
I am setting a session variable, then doing a server.transfer in global.aspx and the page I am going to is saying that session state is not enable and that I should enable it in either the page...
2
by: Robin Tucker | last post by:
In the absence of IAdviceSink support in .NET (well, not the pure vanilla COM version anyway), I need to be able to tell when another process has saved changes to a file, in a similar way some...
8
by: dagecko | last post by:
Hi I would like to know how to detect if a file is binary or not. It's important for me but I don't know where to start. Ty
12
by: ABN | last post by:
I have a C# (.NET 1.1) application in which I loop over a number of files on the hard drive and delete them. A few times, I've experienced an exception that says the file is in use by another...
5
by: Z.K. | last post by:
In C#, using the StreamReader, how do I detect when you get to the end of line. I am reading a text file using the Read() function and I need to detect the \n\r, but everything I try does not...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.