LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need to know if file is open?

Hi all,
I need to know if file (txt file) is open by another preson from another program.
how can i get this info?...
using labview 7.1
regard's
eyal.
0 Kudos
Message 1 of 4
(3,131 Views)
If they have opened it with DENY OTHERS permissions, then your attempt to open it with WRITE access will fail.

That, I suppose, depends on which app opened it.

You might try the FILE COPY function and copy it to some harmless place. It should return an error if the file is open. delete the copy when you're done.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 2 of 4
(3,114 Views)
Just a warning: Some programs might not really keep a file open while a user works with it. For instance, if you are editing or reading a file with Notepad, the file's not really open the whole time. Notepad makes a working copy of the file in memory when you first open it and then closes the file. When you type things you only edit the copy in memory. Not until you save does Notepad reopen the file, alter it, and save it. That will make it difficult for LabVIEW to know if someone is accessing the file.

Other programs like Excel do lock down a file while they use it.

Jarrod S.
National Instruments
0 Kudos
Message 3 of 4
(3,109 Views)
I think this previous forum post (link below) provides some good ideas for checking if a file is currently in use. As Jarrod mentioned, different applications may or may not reserve a file for editing, so it can be diffucult to determine the access state of a file at any given time.
 
 
I hope this helps!
 
Casey Weltzin
Applications Engineer
National Instruments
 
0 Kudos
Message 4 of 4
(3,079 Views)