LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

file exist

How can I check if a file already exists? I need this function as I want to create a specific file every month but only one time, so I hope anybody can help me!!!
 
Marco
0 Kudos
Message 1 of 5
(3,047 Views)
If you only want to make a file once every month then surely it is
safer to use the 'current 'date in the file name thus you will never have two files with the same name !!

Chow
xseadog
0 Kudos
Message 2 of 5
(3,040 Views)
You can use the File Info VI in the File I/O>>Advanced palette and check the error output. If you get an error, the file does not exist.

___________________
Try to take over the world!
Message 3 of 5
(3,032 Views)
This is the way I usually check for the existance of files.  Use the Get File/ Directory information VI and check the return code for 7 (File does not exist).
See example below:
Message 4 of 5
(3,032 Views)
Once upon a time, I searched through the discussion forum archives to find the answer to this very answer.  I ended up doing it the following way (see attached VI); though there are doubtless better ways.  I look at the index output of "Match First String.vi" to see if it is greater than -1.  The input to "Match First String.vi" is from "List Directory.vi"  This is given the name of the directory you want to search (where you store your data files for instance).  You might also check that the user does not try to give the file a blank or "null" name to avoid loss of precious data.
0 Kudos
Message 5 of 5
(3,027 Views)