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.
One way to counter this purely in G is to wrap these calls with a VI like the one below:
- Copy the file to a temporary file.
- Perform the operation on the temporary copy.
- Read the file contents from the temporary file.
- 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.
- Delete the temporary file.