Writes binary data to a new file, appends data to an existing file, or replaces the contents of a file. If a path is wired to the file (use dialog) input, the function opens or creates the file before writing to it and replaces any previous file contents. If a file refnum is wired to the file (use dialog) input, writing begins at the current file position. To append to an existing file, set the file position to the end of the file by using the Set File Position function. This function does not work for files inside an LLB.

![]() |
prepend array or string size? indicates whether LabVIEW includes data size information at the beginning of refnum out when data is an array or string. If prepend array or string size? is FALSE, LabVIEW does not include the size information. The default is TRUE. prepend array or string size? only controls the top-level data size information. Arrays and strings in hierarchical data types such as clusters always include size information. | ||||||
![]() |
prompt (Choose or enter file path) is the message that appears above the list of files and directories, or folder, in the file dialog box. | ||||||
![]() |
file (use dialog) can be a refnum or absolute file path.
If it is a path, this function opens the file specified by the path. This function creates the specified file if it does not already exist. The default is to display a file dialog box and prompt you to select a file. If you specify an empty or relative path, this function returns an error. |
||||||
![]() |
data contains the data to write to the file and can be any data type. | ||||||
![]() |
byte order sets the endian form of the resulting data. Byte order, or endian form, indicates whether integers are represented in memory from most-significant byte to least-significant byte or vice versa. The function must read the data in the same byte order that the data was written.
|
||||||
![]() |
error in describes error conditions that occur before this VI or function runs.
The default is no error. If an error occurred before this VI or function runs, the VI or function passes the error in value to error out. This VI or function runs normally only if no error occurred before this VI or function runs. If an error occurs while this VI or function runs, it runs normally and sets its own error status in error out. Use the Simple Error Handler or General Error Handler VIs to display the description of the error code. Use error in and error out to check errors and to specify execution order by wiring error out from one node to error in of the next node.
| ||||||
![]() |
refnum out is the refnum of the file that the function read. You can wire this output to another file function, depending on what you want to do with the file. The default is to close the file if it is referenced by a file path or selected from the file dialog box. If file is a refnum or if you wire refnum out to another function, LabVIEW assumes that the file is still in use until you close it. | ||||||
![]() |
cancelled is TRUE if you cancel the dialog box. | ||||||
![]() |
error out contains error information. If error in indicates that an error occurred before this VI or function ran, error out contains the same error information. Otherwise, it describes the error status that this VI or function produces.
Right-click the error out front panel indicator and select Explain Error from the shortcut menu for more information about the error.
|
Use the Deny Access function to make sure no other users change the file while you write to it. Use the Set File Position function if you need to perform random access.
Refer to the following VIs for examples of using the Write to Binary File function: