From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
07-12-2011 12:15 PM
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.
07-12-2011 12:21 PM
You can do this in a couple of ways. You can poll or you can use the .NET FileSystemWatcher if you are on Windows. Using that method does not require polling. See this nugget for an example of using it.
07-12-2011 01:05 PM
Sorry, I'm not familiar with the .NET programming. I'm still a beginner and getting to know the sub vi functions.
07-12-2011 01:09 PM - edited 07-12-2011 01:11 PM
In that case it is very simple. There is a vi called list folder in the advanced file functions. It returns an array of filenames. Just run that periodically.
07-12-2011 01:54 PM
Ok, thanks, but the list folder vi in the advanced file functions returns the array of filenames sorted alphabetically. I want to be able to track new files as they are added to the directory. How much work is needed to strip the added filename from the 1D array and append it to a 1D array in memory - essentially creating a 1D array of filnames listed in the order that they were created/added to the directory?
I apologize in advance - my nested loop sorting skills are extremely rusty at this point.
07-12-2011 02:23 PM
Here's a somewhat kludgy way of getting your directory listing by date.
Since List Folder also returns an entry for the folder itself, there will be one Empty entry in the Files list.
07-12-2011 02:28 PM
I usually use the .NET method myself, but if I were forced to poll I would do something like this. I use a variant to hold the list of filenames. I would only poll the folder info, when it has been modified then do the Folder List. Any new files are spotted when the variant attribute does not exist (Replace = FALSE), and this is added to the array.
07-21-2011 03:57 PM
Could you please attach a VI for this example? Thanks!
07-21-2011 04:01 PM
That is a VI snippet. The VI is embedded in the image. All you need to do is drag and drop the image from your browser to a block diagram.
07-21-2011 04:21 PM
@Ravens Fan wrote:
That is a VI snippet. The VI is embedded in the image. All you need to do is drag and drop the image from your browser to a block diagram.
Does not work for me... LV 2009 SP1, MSIE.