Solved

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

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 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