I have been primarily an applications developer but am now migrating into more systems level stuff, so most of this is very new to me. Given the complexity of this question, I wish I could assign it a point value of about 2000 points, but I have confidence the experts will come through, nonetheless.
I need to design a program that will monitor directories and perform actions. Basically, I have an XML file that contains multiple nodes that define the source directory and filename "mask" (e.g. <SOURCEPATH>c:\myDirectory</SOURCEPATH> <SOURCEFILE>abc*</SOURCEFILE>)
For each node, I need to set up a file watcher to raise an event if a new file matching this criteria is added.
Once done, I will process the file, which includes opening it, reading some data, closing it, then copying it to another directory (also defined in the XML). I will then add the file info to a list control on a form.
I have a method that parses the XML file and reads the nodes. My intention is to create a class object (cImportFile) for each node and load the properties with the data from the child nodes in the XML file.
The kicker is: how do I tie each of these to a FileSystemWatcher. I assume I will need one for each node in the XML file (currently there are 8). And then communicate back to the form which one fired and get the actual file properties back to the main form?
So process flow is:
Starting project reads XML file
Process each node, creating a cImportFile object for each one and setting its properties from the XML child nodes data
Assign a FileSystemWatcher to each cImportFile
FSW monitors directory
Have FSW kick off process(es) in the cImportFile object to read data, process it, move the file, communicate back to the form so the list control can be updated.
Continue monitoring and repeat as necessary
Initially, I would also like the process to act as if an event was raised by the FSW so it would process any files that got moved into the monitored directory while the program was not running.
If you need any clarification, please let me know. Dev environment is VB 2005.