Hi,
I want to write a simple program that runs continuously and listens for the FileSystemWatcher events i.e. a new file has appeared in a folder. When the file arrives I want to process that file in some way. The following is code that I have been playing with:
function ImageSorter%Start listeners for file new notifications
fileObj = System.IO.FileSystemWatcher('C:\Dicom\'); fileObj.EnableRaisingEvents = true; l1 = addlistener(fileObj, 'Created', @eventhandlerChanged);%now I want the program to stop and listen for the events and not
% continue to the end.
h = figure('visible','off'); waitfor(h); delete(l1);endfunction eventhandlerChanged(source,arg) arg.FullPathend
If I insert a break point at the end of the ImageSorter program then it works and the eventhandlerChanged function is called when a new file appears in the folder C:\DICOM.
How do I make the function stop running to the end and wait for the listening events?
Jonathan
Best Answer