02-07-2017 12:21 AM
A colleague and I ran across this one today. If the TDMS file is empty (ie. a completely blank, zero byte file), and is attempted to be read, the TDMS Read VI will delete the file. I'd consider this behaviour fairly serious - LabVIEW shouldn't delete any user files, regardless of the type of read error.
The attached zip contains both this VI and test.tdms.
Solved! Go to Solution.
02-07-2017 10:40 AM - edited 02-07-2017 10:41 AM
Confirmed behavior on 2016 and 2015 SP1. It does seem odd and should be fixed. I think the risk of data loss is small, but possible. Interestingly enough the delete happes on the Close function. Open creates a 0KB index file, then after the close both files are deleted.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
02-07-2017 04:28 PM
How did you create the empty 0 byte TDMS file? When you create a blank TDMS in LabVIEW using the open TDMS function, the size is 65 bytes, which tells me that there is some meta data that LabVIEW needs for the file to be read and closed correctly.
If you change the TDMS open option to open (read-only), and follow it immediately by a TDMS close, you will get an error -2503, which states that "Specified file does not comply with TDMS file format standards." The file also does not get deleted in this case.
If you remove the read TDMS and rewire, with the default open option on the TDMS open, the TDMS file doesn't get deleted, and actually changes file size from 0 bytes to 65 bytes. It seems like LabVIEW is adding header data and other stuff as long as there is no TDMS read. If it tries to read the invalid TDMS file, it deletes the file.
Is there a particular reason you are trying to open a 0 byte TDMS file you created externally from LabVIEW, and did you make the file by changing a text file name to test.tdms? If that's how you created it, just note that just because the name says it's a .tdms doesn't necessarily mean it's a valid TDMS file. Also, if that's how you created the 0 byte TDMS file, Windows gives you a warning saying "If you change a file name extension, the file might become unusable." So if that's how you created the file, just note that it is not necessarily a valid way to create a fully-usable TDMS file. If you are creating it any other way please let me know.
I also tried clearing the error, before and after the close TDMS function, and the file was still deleted, so I don't think the file is being deleted because of the error. It might be happening because LabVIEW doesn't recognize the 0 byte file as a valid TDMS file when it tries to read the file.
I'll look into this further to try to get more information and possibly file corrective action for this odd occurance.
02-07-2017 07:03 PM
Thanks for looking into this issue.
The file was created by hand (a text file with a renamed extension), and was just a placeholder for testing some other system functionality. It just so happened the file was passed through the TDMS functions during testing, and suddenly it disappeared from disk. I'm fully aware it's not a valid TDMS file, and was expecting the TDMS functions to throw errors. What I wasn't expecting was the file to be deleted.
I'll do some more testing to see if the file is deleted in any other scenarios.
02-08-2017 08:11 AM
Okay so it is clear that files like this shouldn't exist. But this is still a bug right? Files are being deleted from the file system that were not asked to be deleted. When a CAR gets created please post the CAR number here for tracking purposes.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
02-08-2017 09:53 AM
I'm in the process of submitting a CAR.
I'll post the number here when it's available.
Thank you
02-08-2017 11:27 AM
A CAR has been filed: #629258.
Thank you for finding this bug!
05-23-2018 01:02 PM
CAR 629258 is fixed in LabVIEW 2018