Hey everyone,
I am testing some thing withs AMS to monitor a folder for changes. (For now just alert when a new file is created/found in the folder.) I did not find anything related to monitor a folder, or comparing tables.
The program runs in tray, and monitors a folder for changes. When a new file is found show a dialog with filepath and name.
This is what I have so far but it isn't working as expected.
On Preload:
On Timer:
The issue is that I think this is not very effective, plus the dialog show stays in a loop.
Anyone who can help me out with this code?
I am testing some thing withs AMS to monitor a folder for changes. (For now just alert when a new file is created/found in the folder.) I did not find anything related to monitor a folder, or comparing tables.
The program runs in tray, and monitors a folder for changes. When a new file is found show a dialog with filepath and name.
This is what I have so far but it isn't working as expected.
On Preload:
Code:
-- Find all current files in folder and write it to a file. Files = File.Find("C:\\test\\", "*.*", true, false, nil, nil); TextFile.WriteFromTable(_TempFolder.."\\found.table", Files, false); -- Start the timer to monitor folder. Page.StartTimer(1000);
Code:
-- Find files again and save into variable. findFiles = File.Find("C:\\test\\", "*.*", true, false, nil, nil); -- Read back the previous search results into STRING (because I had no idea how to find something in a table easily) readStringed = TextFile.ReadToString(_TempFolder.."\\monitor.table"); -- Now loop through the CURRENT file list and look for every filename into the previous search results. for j,k in pairs(findFiles) do Finder = String.Find(readStringed, k, 1, false); -- If a filename is not found in the previous results, show dialog. Because a new file is found! if (Finder == -1) then Dialog.Message("Notice", k, MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1); -- do something with the file here if you want. -- Insert the newly found file into the table (so we proceed with monitoring again) Table.Insert(findFiles, 1, k); TextFile.WriteFromTable(_TempFolder.."\\found.table", findFiles, false); end -- Read back the new table to prevent showing dialog of previously found files. readStringed = TextFile.ReadToString(_TempFolder.."\\found.table"); end
Anyone who can help me out with this code?
Comment