Skip to main content
Participant
November 8, 2008
Question

Directory Watcher

  • November 8, 2008
  • 1 reply
  • 1739 views
I am looking for a CFC to work with the Directory Watcher event gateway of Coldfusion. When a file is detected as being written to a Directory I would like the content of same to be appended to another (master) file that is located elsewhere on the server. I have been seeking an informationa resource on these methods but have been unsuccessful to date. Any guidance would be appreciated.

BTW, I do have the DirectoryWather gateway up and running.
This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
November 12, 2008
In the onAdd method, get Coldfusion to read the file and then append it.

<cffunction name="onAdd" output="no">
<cfargument name="CFEvent" type="struct" required="yes">
<cfset data=CFEvent.data>
<cfset addedFile=data.filename>
<cffile action = "read" file = "{absolute_path_to_watcher_dir}\#addedFile#" variable = "textToAdd">
<cffile action = "append" file = "{absolute_path_to_some_other_dir}\someFile.txt" attributes = "normal" output = "#textToAdd#">
</cffunction>