Disk streaming means performing multiple read or write operations within a loop on an open file. Disk streaming saves memory by reducing the number of times a function interacts with the operating system to open and close a file.

Avoid wiring a path control or a constant to a function or VI that reads from or writes to a file, such as the Write to Text File function or the Read from Binary File function. Doing so adds the overhead of opening and closing the file each time the function or VI executes. Instead, implement disk streaming operations to eliminate this overhead.

Use disk streaming in the following situations:

  • In lengthy data acquisition operations where speed is critical. Data streaming is ideal for this situation.
  • To write data continuously to a file while acquisition is still in progress.
Tip For best results, avoid running other VIs and functions, such as analysis VIs and functions, until you complete the acquisition.
  1. Place the Open/Create/Replace File function and the Close File function outside the loop as in the following block diagram.
  2. Place a While Loop on the block diagram and place the Write to Text File function in the loop.
  3. Place the Close File function after the loop and wire the functions together.

In this disk streaming design pattern, the VI continuously writes to a file within the loop without the overhead associated with opening and closing the file in each iteration.

Block diagram showing Open/Create/Replace File before loop, Write to Text File in loop, Close File after.