File modification alert from windows api
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Fedor Simkovic
el 19 de Feb. de 2012
Editada: Image Analyst
el 17 de Oct. de 2013
Hello!
I want my matlab program to receive a notification from or through the windows api whenever a file is externally modified (a picture) so that it can immediately load the new file. I am basically trying to avoid using a timer function as that one only looks for changes once a time interval and when i make the interval too small it produces problems.
Thanks!
2 comentarios
Image Analyst
el 19 de Feb. de 2012
What problems do you get? What's wrong with a timer? What file parameters are you checking? The date/time via fileinfo()?
Respuesta aceptada
Jiro Doke
el 20 de Feb. de 2012
Here's a simple example in MATLAB (assuming you have an image called "mypicture.jpg" in the current folder:
% Watch this folder
w = System.IO.FileSystemWatcher(pwd);
% Watch a particular image file
w.Filter = 'mypicture.jpg';
% Notify when the file changes
w.NotifyFilter = System.IO.NotifyFilters.LastWrite;
% Create a listener for change
addlistener(w, 'Changed', @changedFcn);
% Start watching.
w.EnableRaisingEvents = true;
You also need to create a function like this:
function changedFcn(obj, eData)
fprintf('Changed: %s\n', char(eData.FullPath));
end
Try modifying the image.
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!