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

Updated Mar 26, 2018

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. Set the from (0:start) enumerated input of this VI to end. Connect the refnum out 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. The End of Line Constant 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.

 

Additional Information

For more information about the Set File Position function, see LabVIEW 2017 Help: Set File Position.

WAS THIS ARTICLE HELPFUL?

Not Helpful