Error 8 in LabVIEW When Writing to or Reading From a File

Updated Mar 9, 2023

Reported In

Software

  • LabVIEW

Issue Details

When I run a LabVIEW program that uses File I/O commands, I get an error message:

Error 8 Occurred at Open/Create/Replace File Possible reason(s): LabVIEW: (Hex 0x8) File permission error. You do not have the correct permissions for the file.

Solution

Error 8 can occur for various reasons including file permissions or VI settings.
  • Check any other open applications and make sure that they close the file before LabVIEW opens it.
  • If you have manually opened the file, make sure you close it before you run your program.
  • If you have made changes to your file structure, ensure you are setting the right directory for your file I/O VI.
  • Open the block diagram of the high-level File I/O function, such as Open/Create/ReplaceFile VI
    • Change the open mode input on the Open File VI to a numeric constant of 1.
    • If you created a constant or a control directly from the input terminal, select the read-only option from the drop-down menu.
  • Ensure that the Windows account has permission to edit the file. If you are editing another account's file, you may not have permission to do so.
  • If you are creating an executable, the source files included that the application is trying to access may be in the wrong directory for the target you are running it on (double check where your Source Files will be placed).
  • In case you are writing to or reading from a file located in an external USB drive, try using another drive. 
  • If on a Real Time OS, make sure that the Linux Security Shell is not getting in the way and that you are writing/reading to a folder the lvadmin has access to.

Additional Information

Also consider the file location which you are communicating with. Files originating from a non-writable medium such as a CD-ROM are marked as read-only by the operating system. Any high-level File I/O function that uses the Advanced File I/O Open File VI function with a read-only file will generate a file permission error. For example, the Open/Create/Replace File VI uses the advanced function, Open File VI.

The reason for this is due to the open mode input on the Open File VI. It defaults to a value of zero, which corresponds to "read and write." To open a read-only file, you need to change the open mode input to one (1), which corresponds to "read-only." Otherwise, you will get the file permission error.