Archived: Why Do I Get Error 4 Using the Read File VI in LabVIEW?This document has been archived and is no longer updated by National Instruments
I have a file that I am reading using the Read File VI in LabVIEW. It reads all the contents of the file correctly, but then gives me the following message Error 4 Occurred at Read File in XXX.vi. Possible Reasons: End of File when it gets to the end of the file. I even get the same error when I use the Read From Text File VI example from National Instruments. How can I prevent this error?
The information in this article pertains to older versions of LabVIEW, the Read From Text File VI was rewritten completely and this information does not apply to later versions of LabVIEW.
This is expected behavior when the end of the file is read. The Read From Text File VI example is designed so that the While Loop that reads the file will terminate if the user presses the stop button or if an error occurs. Then it simply displays the error in a pop-up dialog box. Even though Error 4 shows up as an error, it is not fatal; it simply informs the user that the end of the file has been reached. By handling the error appropriately you can prevent the error from showing up. The following are some ways you can prevent this error from displaying:
KnowledgeBase 38QH733E: Why Do I Get Error 4 When Calling the Read LabVIEW Measurement File VI Multiple Times?
KnowledgeBase 3EKI61T0: Why Do I See "Error 4 Cccurred at Read File in Read BMP Data.vi" When Assigning a Custom Icon in Application Builder?
Report Date: 04/11/2003
Last Updated: 07/23/2014
Document ID: 2WACHODS