Watching Folder for New File Without Polling in LabVIEW

Updated Sep 5, 2019

Reported In

Software

  • LabVIEW

Operating System

  • Windows

Issue Details

I want my LabVIEW code to check for files being placed in a folder by a different process. Polling the folder is too slow for my application.
Is there a method like an event structure, which executes, when a new file is placed in the folder?

Solution

You can detect the creation of a new file without polling by using the FileSystemWatcher Class of Microsoft.

You can find a documented example in the Attachment section.

This example creates a FileSystemWatcher .NET object, and registers an event on it.
Each time an event occures, a Callback VI is executed.

Additional Information

This method can also be used on other file changes like deletion or modification.

Attachments