How to write daemon in UNIX

Hi Guys,

I hope this is the right forum to post this.

I have a directory where files will be dumped at any time of the day and I want to run scripts as soon as new files come into the directory.

How can I write a daemon that detects when new files have been uploaded to the directory?

Can someone please put some sample codes on how to create daemon with brief explanation.

Thanks very much.

search for directory listeners