LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I loop a search algorithm to look for new files in a directory and store the file names in a string?


@MoReese wrote:

That's good if you have your solution, but I wanted to give another method for monitoring file activity.  I used the File/Directory Info function to get the last modified date.  The other two VIs are simple FGVs that read and write the date modified.  It's a simple comparison from there.  The VI will detect if new data has been written to the file.  You can do something similar for the entire folder (awaiting a new file) by using the List Folder function to acquire the files and then monitor for the newest in a similar fashion as the attached.



Nice idea.  But it falls apart if the file directory changes because somebody copied in a file that is older than the newest file.

0 Kudos
Message 21 of 24
(716 Views)

That's true, but this example is application specific designed to meet a specific need.  Of course, it can be enhanced to prevent older files from falling through the cracks but this may work for his application, depending on how much control he has over the process.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 22 of 24
(711 Views)

I don't know if your method truly meets their needs.  In message 5, the OP says "I want to be able to track new files as they are added to the directory."  This could have a few different meanings, one of which is a file that might be newly added to the directory, but not necessarily newer in file date than a file already in the directory.

0 Kudos
Message 23 of 24
(704 Views)

@galimba wrote:

I'm not too familiar with the loops and am having trouble setting up this function.  Basically, I want the program to continually run, and as a file is placed/created in a certain directory, the program will take the file name and append it into a string array.


Yes, he states placed/created, so that may indicate existing files may be written to this directory, in which case the algorithm will have to be modified.  But, if the files are newly created only, this will work fine, but it would make sense, for flexabilities sake, to incorporate a method to handle such occurances, unless he knows for certain that the use of this directory won't change.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 24 of 24
(694 Views)