Tuesday, December 11, 2007

How to implement your FileSystemWatcher

How to implement your FileSystemWatcher

Step 1

Once you have created your FileSystemWatcher, you need to set certain parameters for it.

Step 2

We will do this in the Form_Load event. What we are trying to do is to create a FileSystemWatcher event that will detect creation of file with the extension TXT to it’s directory only – not inclusive of subdirectories. This is all configuring with the codes below.

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

FileSystemWatcher1.Path = "c:\im"

FileSystemWatcher1.Filter = "*.txt"

FileSystemWatcher1.IncludeSubdirectories = False

FileSystemWatcher1.EnableRaisingEvents = True

End Sub

Step 3

Then to implement our FILE CREATION event,

Step 4

Go to your FileSytemWatcher1 object and then select it’s events under Declaration in the Created

Step 5

Under this control, use the MsgBox to notify user that a TXT file has been created in your folder called IM.

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

MsgBox("A newly created TXT file is detected")

End Sub

Edited By:Melanie Michael Jominin

© 2001 ISC/Inner Esteem

All rights reserved. All other product names and trademarks are registered properties of their respective owners.

301001

How to create FileSystemWatcher

How to create FileSystemWatcher

Step 1

To create Flesystemwatcher, go to your Toolbox. Under the component tab, pull the controlbox into your form.

You can also declare this component using the following codes

Dim mwatcher as New System.IO.FilesystemWatcher()

What is FileSystemWatcher

What is FileSystemWatcher

FileSystemWatcher is a component that allows you to monitor changes to your filesystem such as creation of a new file. FilesystemWatcher do not have a user interface.

How to add text to your Toolbar

How to add text to your Toolbar

Step 1

To add text to your Toolbar, click on Button under your toolbar properties.

Step 2

Then when a window popup, change the text to let’s say Sample1.

Step 3

Click on Ok when done.

An example of output looks like this above.