LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

check existing file

whats the best way to check if a file path exists?
0 Kudos
Message 1 of 6
(3,443 Views)
If you only need to check if a file exists use from File I/O>>Advanced>>Access Rights function. Then check for error 7. In this case the file or the path is missing. You can also use the Open File function but if the file exists it will be opened and you need to close it.

Another way is to use the List Directory function. You will get error 7 if the directory is missing otherwise you will get an array of filenames which can be empty if no files are in it. This is usefull if you plan to give your files consecutive numbers. Sort this array and you will get the name of the file with the highest number. This is more effective than going through a loop and checking each file.
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
Message 2 of 6
(3,432 Views)
Hi

One fairly simple way is to use the File/Directory Info VI in File I/O >> Advanced File Functions.
If the path doesn't exist you'll get Error 7.
Message 3 of 6
(3,429 Views)
Several solutions in mind
- Read the file info, and check for error 7
- Try to open the file, and check for error 7. If the file has been successfully opened, proceed with the next operation. This method is the most efficient if you intend to use low level file access functions. If you prefer to use high level functions, it is necessary to close the file before further processing. In this case the previous method is better

CC
Chilly Charly    (aka CC)
Message 4 of 6
(3,423 Views)
Hum, too late... 😠
I should disconnect the phone while trying to reply a thread !!! 😉

Edition : Thanks for the stars. That's a rather quick reaction !.. 😮

Message Edited by chilly charly on 03-23-2005 01:18 PM

Chilly Charly    (aka CC)
0 Kudos
Message 5 of 6
(3,421 Views)
CC

Didn't someone say something about great minds thinking alike ... 😉
0 Kudos
Message 6 of 6
(3,415 Views)