Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Folder Monitoring Application Using File System Watcher in .NET 2.0.

Author: DevASP
Download Source Code : 596_FileWacher.zip

In this simple article you will learn that how you can Monitor a folder using File system Watcher

Simply just create New Project of console application in VB.

 

Drag one text box, one button, two List view control on form.

 

This Application Monitor Specific folder, when you create a new file or delete any file it tells you that what’s happened. This is very use full Application for Beginners.  

 

Insert FolderBrowserDialog and FileSystemWatcher in your application.

 

 

Now just write code against these events

 

 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 

        Me.Text = "DevAsp"

        Me.BackColor = Color.Ivory

 

        ListView1.BackColor = Color.LightGray

        ListView3.BackColor = Color.LightGray

        ListView1.ForeColor = Color.Brown

        ListView3.ForeColor = Color.Red

        FileSystemWatcher1.Path = "c:\"

 

    End Sub

 

   

 

    Private Sub FileSystemWatcher1_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Created

 

        ListView1.Items.Add(e.Name)

 

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

 

        FolderBrowserDialog1.ShowDialog()

        inp.Text = FolderBrowserDialog1.SelectedPath

        FileSystemWatcher1.Path = inp.Text

 

    End Sub

 

    Private Sub FileSystemWatcher1_Deleted(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Deleted

 

 

        ListView3.Items.Add(e.Name)

 

    End Sub

Article Comments
its nice example,helped a lot

Posted on 1/6/2010 7:26:46 AM by deepak

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Implementing Multiple Criteria Filtration of Data in Data Grid in .NET 2.0

Disclaimer - Privacy
© 2002-2017 DevASP.net