Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Open/Create/Replace File Function

LabVIEW 2013 Help

Edition Date: June 2013

Part Number: 371361K-01

»View Product Info

Owning Palette: File I/O VIs and Functions

Requires: Base Development System

Opens an existing file, creates a new file, or replaces an existing file, programmatically or interactively using a file dialog box. This function does not work for files inside an LLB.

Details  Example

prompt is the message that appears above the list of files and directories or folder in the file dialog box.
file path is the absolute path to the file. If you do not wire file path, the function displays a dialog box from which you can select a file. If you specify an empty or relative path, this function returns an error.
operation is the operation to perform. Error 43 occurs if you cancel the dialog box.

0open (default)—Opens an existing file. Error 7 occurs if the file cannot be found.
1replace—Replaces an existing file by opening the file and setting its end of file to 0.
2create—Creates a new file. Error 10 occurs if the file already exists.
3open or create—Opens an existing file or creates a new file if one does not exist.
4replace or create—Creates a new file or replaces a file if it exists. This VI replaces a file by opening the file and setting its end of file to 0.
5replace or create with confirmation—Creates a new file or replaces a file if it exists and you give permission. This VI replaces a file by opening the file and setting its end of file to 0.
access specifies how you plan to access the file. The default is read/write.

error in describes error conditions that occur before this node runs. This input provides standard error in functionality.
disable buffering specifies if the file opens without buffering. The default is FALSE. If you want to read or write a data file to a Redundant Array of Independent Disks (RAID), consider opening the file without buffering to speed up data transfers. To disable buffering, wire a TRUE value to the disable buffering input.
Note  If you have a small amount of data to transfer, you might not notice a difference if you disable buffering.
(Mac OS X and Linux) LabVIEW ignores this input.
refnum out is the reference number of the open file. The value is Not A Refnum if the file cannot be opened.
cancelled is TRUE if you cancel the file dialog box or if you do not select the replacement in an advisory dialog box.
error out contains error information. This output provides standard error out functionality.
file can be a refnum or absolute file path. If it is a path, this function opens the file specified by the path. The default is to display a file dialog box and prompt you to select a file.

If you specify an empty or relative path or if the file does not exist, this function returns an error.

Open/Create/Replace File Details

You can optionally specify a dialog prompt or default filename. Use this function with the intermediate Write File or Read File functions. Use the Close File function to close the reference to the file.


Refer to the Tab-Delimited Data.lvproj in the labview\examples\File IO\Spreadsheet\Tab-Delimited Data directory for an example of using the Open/Create/Replace File function.


Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit