Groups | Blog | Home
all groups > sql server notification services > october 2004 >

sql server notification services : FileSystem Watcher


Richard
10/21/2004 3:33:01 AM
Can anyone point me in the direction of a custom filesystem watcher that
watches for files other than XML?

The situation I have is files coming into folders where they then have to be
loaded in SQL Server. The files will not be XML files (and I can't specify
that they should be). I need a watcher to watch for the existence of the file
and then kick off a stored procedure/DTS. I have a custom event provider to
fire a stored procedure but can the existing filesystem watcher call this
custom event provider? The number of files to be dropped in the folder is
very infrequent and I need to send notifications that the data has arrived
and loaded etc so I thought NS would be good for this.

Any help or reference to where someone else has done this would be greatly
Joe Webb
10/21/2004 9:28:17 AM
Hi Richard -

You can write your own using the .NET framework FileSystemWatcher class.

Check out
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiofilesystemwatcherclassfiltertopic.asp

for more details.

Once a new file is recognized, you can use read and submit the events to
SQLNS via your sproc/DTS package.


HTH...
Joe Webb

~~~
Get up to speed quickly with SQLNS
http://www.amazon.com/exec/obidos/tg/detail/-/0972688811



[quoted text, click to view]
Shyam Pather [MSFT]
10/21/2004 10:01:15 AM
Richard,
You will have to write your own custom event provider, but inside it you can
use the FileSystemWatcher class that the .NET framework provides. THis is
the same class that our built-in NS FileSystemWatcher Event provider uses
internally. You can configure it to watch a directory for any type of file
and invoke a callback when a file is added (or modified, as you choose). You
can then open the file and submit the appropriate events into your NS
application.

Chapter 8 of my book
(http://www.amazon.com/exec/obidos/tg/detail/-/0672326647/ ) provides
detailed explanations and code samples for building custom event providers.

Hope this is helpful.
-shyam

--
Learn more about SQL-NS:
http://www.amazon.com/exec/obidos/tg/detail/-/0672326647/
---------------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
---------------------------------------------
[quoted text, click to view]

AddThis Social Bookmark Button