Solved

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

Posted on 2004-08-17
4
198 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now