开发者

In a .Net web site, what are my options for sending email alerts when folder contents change?

I don't know much about the .Net environment, so my first idea was to just write a console app that scans the folder for new content, and then emails alerts out. Then put the .exe as a scheduled task on the server, executing every few minutes. This seems pretty archaic 开发者_开发百科to me though. Is there a more elegant way to do this for my website?


No matter what type of application you choose the way to get notifications about folder changes in .NET is through the FileSystemWatcher class. A good approach would be to create a Windows Service which will run in background and listen for notifications.


http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx


You can use the FileSystemWatcher. Create a Windows Service that constantly runs, and attach an Event to the Watcher to send out emails.

Note that this reports every change, sometimes multiple ones (e.g., moving a file is a delete and create I think), so you may want to limit the number of emails you sent. Experiment a bit before sending hundreds of emails or so - been there, done that :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜