LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Verifying files exist?

Hello,

I am working on a program that requires checking at each iteration of a loop whether or not a file exists.  Currently, the only way I have found to accomplish this is by using a 1D search along with List Folder (other methods of checking the existence of the file return and error and stop executing if the file does not exist).  However, the List Folder method seems to be rather slow, especially because the files are all in different folders and these folders are on a network.

Does anyone know of a vi that can take a path as input and return anything that can be used to determine if the file exists without crashing if the file does not exist?
Thanks!

Cameron
0 Kudos
Message 1 of 6
(7,192 Views)

Open file?  Check for error and clear error.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 2 of 6
(7,186 Views)
The error is good information. Just wire the error (e.g. to a case structure) and use it in the code for decision making. There is no need to stop the program on error!
 
On older LabVIEW version, just use the error out of "File/directory info".
In LabVIEW 8.2, there is a tool "Check if file or folder exists". It has some advantages, e.g. when dealing with links.
Message 3 of 6
(7,184 Views)

File info also does the job, look for error code 7- file does not exist.  this can be amde into a simple subvi which returns a boolean.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 4 of 6
(7,182 Views)
Aha, thanks! I hadn't made the connection that wiring the error out would prevent the program from terminating.
Cameron
0 Kudos
Message 5 of 6
(7,179 Views)
What you are seeing is the "auto error handling", which is enabled by default. It pops you an error dialog every time you generate an error and the error output is not wired.
 
Go to the options for the block diagram if you want to turn off this behavior. A better idea is to always wire the errors. 😉
Message 6 of 6
(7,173 Views)