I am going to be creating an application which will monitor a folder, which could be a network folder and when new files are added in that folder it will notify the application. On notification application will import those files names into a listbox and will give the option to user to organize(move) those files into a different directory.
Two main things here,
1. I have to implement a logic for monitoring the new files in the folder.
2. I have to move it into new directory and in some cases I will have to create those new directories as user specify.
For the first step I am confused to either implement it as a windows service using FileSystemWatcher class, example can be seen here.
http://www.codeproject.com/Articles/32591/Creating-a-Windows-Service-for-Watching-System-Dir
or do a file check based on timer, lets say every 5 minutes.
If I do it as a service how can the service notify application?
I would integrate this into the application – you might run into problems (permission-wise) watching a network folder from a windows service.
Some references and sample code:
To avoid some pitfalls (watching files on a network folder might be sometimes unreliable) poll the folder additionally for example every 10 minutes…
IF you really want to do it as a Windows Service you can use any form of IPC to notify the application – TCP or UDP or “shared memory” or Pipes or whatever…