How Do I Append to a Text or Binary File in LabVIEW?

Updated Jan 17, 2019

Reported In

Software

  • LabVIEW

Issue Details

I am using the Open/Create/Replace File function to open a file. When I write to the file multiple times, the data stored in the file is being overwritten with new data on each write. How do I append data to the end of the file on each file write?

Solution

Use the Set File Position function found on the Functions palette under Programming»File I/O»Advanced File Functions. 
  1. Set the from (0:start) enumerated input of this VI to end (see (1) in example).
  2. Connect the refnum out (see (2) in example) from the Set File Position function to the file input of the VI that is writing to the file. This will append new data to the end of the file. 
The image below shows an example of appending a string value to a text file.

 

Additional Information

The End of Line Constant (see (A) in example) is concatenated to the string input in this case to create a new line for every value written to the file. This constant is not needed if an array type is entered into the Write to Text File function because it will automatically append it to the value. 

WAS THIS ARTICLE HELPFUL?

Not Helpful