Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

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

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
ERP_CodeWarrior
Asked:
ERP_CodeWarrior
2 Solutions
 
AerosSagaCommented:
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now