Example Code

Check if a Particular File is Open in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Description

This example covers how you check if a particular file is open on your computer in LabVIEW. You also can use this functionality to share a single file between multiple LabVIEW users or an .exe.

How to Use

Most of the File I/O VIs and Functions will give you an error if the file in question is open when the VI executes.

To check if a file is open, you can use a File I/O function, such as Open/Create/Replace File, and evaluate the error code to see if the file is open. For example, Open/Create/Replace File gives error code 5 if you attempt to open a file that is already open.

See the attached VI for an example.

checkiffileopen.png

Related Links

Determine the Active Window in LabVIEW

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors