Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How do I code a file/folder/DB "change detection" monitor in .NET application?

Posted on 2004-08-17
4
202 Views
Last Modified: 2010-04-23
I must program an application system containing workflows that will require "change detector" triggers in order to set workflow events in motion, so I must create monitors that will keep watch for changes in files, folder contents, and database tables.

This system is part of a commercial application that will exist on both J2EE and .NET platforms.

I've never done this kind of "change detection" monitor. Can someone describe how to approach it, or point me toward a tutorial or resource that would shed some light?
0
Comment
Question by:ERP_CodeWarrior
4 Comments
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 125 total points
ID: 11820713
0
 
LVL 17

Assisted Solution

by:AerosSaga
AerosSaga earned 125 total points
ID: 11821063
Create a new form and add a Button to it called Button1. Add this code then delete, modify, rename or create a file in your c:\ directory. The application will write the change to the output window.

Imports System.IO

    Protected Sub Button1_Click(ByVal sender As Object,  _
             ByVal e As System.EventArgs)

        Dim objWatcher As New System.IO.FileSystemWatcher()
        Dim objResult As System.IO.WaitForChangedResult
        Dim strChange As String
       
        objWatcher.Path = "c:\"
       
        objWatcher.IncludeSubdirectories = False
       
        objWatcher.Start()
        objResult = objWatcher.WaitForChanged(WatcherChangeTypes _
                                      .All)
       
        Select Case t.ChangeType
            Case WatcherChangeTypes.Changed
                strchange = "Modified"
            Case WatcherChangeTypes.Created
                strChange = "Created"
            Case WatcherChangeTypes.Deleted
                strChange = "Deleted"
            Case WatcherChangeTypes.Renamed
                strChange = "Renamed"
        End Select
       
        console.WriteLine(objResult.OldName() & " was " & strchange & _
                        " at " & format(now(), "DD/MM/YYYY HH:MM:SS"))
    End Sub

Regards,

Aeros
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question