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... 7 1428
> 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
"Roger" <ro***@pcsreven uecontrol.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
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
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******@WEDEL IVERcc3.com> wrote in message
news:Xn******** *************** ***********@207 .46.248.16... "Roger" <ro***@pcsreven uecontrol.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
It's 'The eternal question', then...
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:uO******** ******@TK2MSFTN GP15.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
glen,
Answers on this are
do while loop condition = false
Try
Open a file
When found leave set the condition to true
Catch
threading.threa d.sleep(1000)
'And set a max if you want
End
I hope this helps something
Cor
Interesting.... I'll try that. Thanks.
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:uf******** ******@tk2msftn gp13.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.threa d.sleep(1000) 'And set a max if you want End
I hope this helps something
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 file may have been created but a
crash occurred at that point in time (while it was being created), damaging
the file. Now, my program which needs to read from this file, should first
check that it's in good condition, and that it hasn't been...
|
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:
a. handled by the main processor (e.g. x86)
b. not supported (e.g. Sparc running Solaris)
c. emulated in software (e.g. Alpha running Linux)
By "unaligned word access" I mean access to a 16-bit word
|
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 C#? If not, how can I
determine the state of the screen saver?
--
-Anthony
|
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 applications.
|
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 directive or web.config file.
it is enabled in both
has anyone else had similar problems?
Adrian
| |
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 programs state "file has
changed on disk, reload?". I was wondering what strategy I should use in
order to check temp files I have created to see if they have been changed by
another process. My initial thought is to periodically check the files,...
|
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
|
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 process.
So, my question is... Is there anyway to loop over the files and determine
if the files are able to be deleted before trying to delete (so the
exception won't be thrown)?
Thanks.
|
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 work. I am sure that
this probably fairly simple, but I have not been able to figure it out.
Z.K.
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |