Showing results for 
Search instead for 
Did you mean: 

Writing a string to binary file

Go to solution

Writing a string to binary file

Hello Community


I am trying to write to a binary file that is read with Delphi as well as with LabView. While writing strings in the binary file Delphi uses 1 byte at the beginning for the string length and then writes the string. LabView does it differently though. Any Ideas of how can I write a byte array of a string replicating the Delphi format?


Thanks in advance

0 Kudos
Message 1 of 5
Accepted by topic author AnaZerpa
09-11-2017 04:37 AM

Re: Writing a string to binary file

Hi Ana,


switch off the array/string size when writing the string to your binary file (it's an input parameter of the WriteBinaryFile function)!

Then write your own string length indication byte in front of the string (or prepend the length byte to the string data)…

Best regards,
CLAD, using 2009SP1 + LV2011SP1 + LV2017 on Win7+cRIO
Kudos are welcome Smiley Wink

Message 2 of 5

Re: Writing a string to binary file


You can simply everytime write at fisrt time an octet into binary file, before to write your data(String).

This obligate you to use fonction write to Binary file two time successively.


0 Kudos
Message 3 of 5

Re: Writing a string to binary file

I am in the boat of prepending the length byte to your data before writing to the file.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Message 4 of 5

Re: Writing a string to binary file

So how does Delphi handle strings longer than 255 bytes?


G# - Award winning reference based OOP for LV, for free! ADDQ VIPM
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
0 Kudos
Message 5 of 5