Summary: In this lesson, you will learn about file I/O operations.
File I/O operations pass data to and from files. Use the File
I/O VIs and functions located on the Functions>>All
Functions>>File I/O palette to handle all aspects of file
I/O, including the following:
The File I/O palette is divided into four types of operations: high-level, low-level, advanced, and express.
Use the high-level File I/O VIs located on the top row of
the Functions>>All Functions>>File I/O
palette to perform common I/O operations. Refer to the
High-Level File I/O VIs section
for more information about the high-level File I/O VIs.
You can save time and programming effort by using the high-level VIs to write to and read from files. The high-level VIs perform read or write operations in addition to opening and closing the file. If an error occurs, the high-level VIs display a dialog box that describes the error. You can choose to halt execution or to continue. However, because high-level VIs encapsulate the entire file operation into one VI, they are difficult to customize to any use other than the one intended. Use low-level VIs for more specific tasks.
Use the low-level File I/O VIs and functions located on
the middle row of the Functions>>All Functions>>File
I/O palette and the Advanced File I/O functions
located on the Functions>>All Functions>>File
I/O>>Advanced File Functions palette to control
each file I/O operation individually.
Use the principal low-level functions to create or open a file, write data to or read data from the file, and close the file. The low-level VIs and functions can handle most file I/O needs. Refer to the LabVIEW Basics II: Development Course Manual for more information about the Advanced File I/O functions.
The Express VIs on the File I/O palette include
the Read LabVIEW Measurement File Express VI
and the Write LabVIEW Measurement File Express
VI. The LabVIEW measurement data file (.lvm) is
a tab-delimited text file you can open with a spreadsheet
application or a text-editing application. In addition to
the data an Express VI generates, the .lvm file
includes information about the data, such as the date and
time the data was generated.
Refer to the Data Acquisition and Waveforms section, for more information on using the File I/O Express VIs.
Use the default LabVIEW Data directory to store the data files
LabVIEW generates, such as .lvm or
.txt files. LabVIEW installs the LabVIEW
Data directory in the default file directory for your
operating system to help you organize and locate the data
files LabVIEW generates. By default, the Write LabVIEW
Measurement File Express VI stores the .lvm files
it generates in this directory, and the Read LabVIEW
Measurement File Express VI reads from this directory. The
Default Data Directory constant, shown in Media 1, and the Default Data Directory property also
return the LabVIEW Data directory by default.
Select Tools>>Options and select
Paths from the top pull-down menu to specify a
different default data directory. The default data directory
differs from the default directory, which is the directory you
specify for new VIs, custom controls, VI templates, or other
LabVIEW documents you create.
A typical file I/O operation involves the following process:
"A full introductory course on programming with LabVIEW."