Solved

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

Posted on 2004-08-17
4
204 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
[X]
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
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

623 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