Preventing TDMS File Permission Changes by TDMS Defragment Function in LabVIEW

Updated Mar 25, 2024

Environment

Software

  • LabVIEW

I am using the TDMS Defragment function in my application and have noticed that the file permissions granted for 'Users' are removed when using this function. How can I set the TDMS file permissions back in LabVIEW?

Both TDMS Defragment and TDMS Delete Data create modified content in a temporary file, then move the temporary file over the original. This has the side effect that the resulting file inherits default permissions from the temporary directory. The primary workaround in LabVIEW is to use the System Exec VI with icacls to re-add those permissions, as depicted in the image below.

1.PNG

One way to counter this purely in G is to wrap these calls with a VI like the one below:

  1. Copy the file to a temporary file.
  2. Perform the operation on the temporary copy.
  3. Read the file contents from the temporary file.
  4. Overwrite the contents of the original file with the contents from the temporary file. Since the file is not deleted, this will maintain the permissions.
  5. Delete the temporary file.

image.png

 

"Users" permission have been granted to the TDMS file :

3.PNG