Error 5, 7, or 8 When Using the Delete File Function in LabVIEW

Updated Oct 22, 2018

Reported In

Software

  • LabVIEW

Issue Details

I think I am closing and deleting my file properly. Why is LabVIEW giving me one of the following errors?

Error 8: File permission error


Error 7: File not found



Error 5: File already open

Solution

Usually when these errors show up at the Delete file function, a reference is still open to the file you are trying to delete as a result of a previous operation on the file. 

An example of the most common case:
 
Even though the second Open/Create/Replace File function overwrites the original file, the refnum generated by the first Open/Create/Replace File Function is still valid for operations on the file (for example, you can write to the overwritten file using the first refnum - it even retains its original current file position). Until you close all open references (refnums) to a file, you cannot delete that file. 

Correct Implementation: