Hello,
I'm trying to write a script that will watch a file system (folder with sub folders) and run a function every time a new file is automatically generated from another system and placed in the watched directory. I also need the script to listen for files that are copied into the watched directory.
once this works, i plan on compiling it as a standalone .exe that will run 24/7 and process new files.
Please let me know what I am missing here to keep it running. Below is what I have so far, it does absolutely nothing when i copy a new file into the directory:
function continual_process() process = true; while process path_to_watch = 'C:\Users\3cal-shape\Desktop\test'; fileObj = System.IO.FileSystemWatcher(path_to_watch); fileObj.Filter = '*.slm'; fileObj.EnableRaisingEvents = true; addlistener(fileObj,'Created', @eventhandlerChanged); addlistener(fileObj,'Changed', @eventhandlerChanged); endend
function eventhandlerChanged(source,arg) disp(source) disp('found new file') end
Best Answer