02-14-2022 03:12 AM - edited 02-14-2022 03:42 AM
Is it possible to monitor a folder for any new files using teststand?
02-14-2022 03:30 AM - edited 02-14-2022 03:37 AM
Hi uma1328,
Can you be more specific about what you would like to do with the folder? Are you interested if the folder exists or in the folders contents......?
Ah just read the title, my bad.
Steve
02-14-2022
03:42 AM
- last edited on
10-23-2024
11:30 AM
by
Content Cleaner
There is a FindFile function that can be built into an Expression using the expression browser. You could use that to poll the folder for new entries. See here for details of the function.
02-14-2022 03:51 AM
Hi Steve,
Thank you for your reply.
Is this FindFile function is used to find any particuar file? or can we monitor any number of files which is created newly in that particular folder? ex: any file like .jpg, .txt, .seq?
02-14-2022 04:03 AM - edited 02-14-2022 04:08 AM
Yes, the first parameter for FindFile is the path of the file that you would like to find, you can specify the path to any time of file that you like (as far as I am aware).
If you are looking for the arrival of new files into your folder then I would go for a code module, the file operations within the code module language (e.g. LabVIEW) will give you far more flexibility when it comes to doing what it sounds like you would like to do.
02-14-2022 05:38 PM
You can also use .NET File.Exist() and other System.IO methods for free (no additional coding needed since it is installed with Windows).
02-15-2022 11:49 PM - edited 02-16-2022 12:21 AM
Hi Michał Bieńkowski,
Thank you for your reply. I wanted to know whether this .NET File.Exist() function will try to find any specific file or it will give any arrival of files recursively? If i place set of files in a folder, teststand should detect the arrival of the files in the folder.
This link has a solution to my query using python:
How to create a watchdog in Python to look for filesystem changes | The Python Corner
Similar solution i need using teststand.
02-16-2022 03:19 PM - edited 02-16-2022 03:26 PM
What do you mean by "recursively"? In subfolders? If so, File.Exist() will not work since you need to provide file path. I think there is also something to list folder files (perhaps even recursively). So, you can call this function in a while loop until you find new file in the folder (or if number of files change). I recommend to look at System.IO lib at Microsoft site to see what can be accomplished: https://docs.microsoft.com/en-us/dotnet/api/system.io?view=net-6.0
Something similar to your Python example would be FileSystemWatcher, I guess. But I never used it and honestly I don't know how to handle .NET events in TestStand. That is why I suggested polling loop.