Error 5: LabVIEW: File already open when Writing, Deleting or Replacing File

Updated Oct 6, 2023

Reported In


  • LabVIEW

Issue Details

  • I am trying to use File I/O VIs in LabVIEW to write to, delete or replace a file, but when I run the code, a VI returns the following error:
  • I am trying to use the Report Generation Toolkit in LabVIEW, but I keep receiving the following error. How can I fix this?
Error 5 occurred at an unidentified location 

Possible reason(s):
LabVIEW:(Hex 0x5) File already open


Error 5 is generated when a LabVIEW File I/O VI is unable to open a reference to an existing file because another process already has an open reference to the file. This can occur if LabVIEW, another application, or your operating system has already opened the file for writing. Follow the steps below to resolve the issue:
  • If you have another application that is reserving your file (like backup applications, NI DataFinder, or desktop search applications):
    • Add error handling to retry the file operation when Error 5 occurs.
    • Disable the offending application.
  • If you are trying to perform multiple, simultaneous file writes on the same file within your LabVIEW VI either:
    • Serialize the operation.
    • Use an asynchronous File I/O API (like the TDMS Advanced API)
  • If using the Application Builder:
    • Try cleaning the build directory and then rebuilding your application. In the project, right-click on Build Specification»Clean.
    • Try changing the location of the build directory.

Additional Information

Error 5 is not guaranteed to be thrown in the event that a file is already open and should not be relied upon as a method of preventing race conditions or as a method of controlling file access.

Microsoft Windows is case-insensitive which means that this error may arise also when a file with the same name and on the same location but with different case is trying to be created, while the original file reference is used by another application.