Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 35,677 times

Contents

Related Categories

Watching Folder Activity in VB.NET - Introduction

JayeshJain

Introduction

Have you ever wanted to write an application that constantly monitors a folder and raises events when there is any activity in that folder? In the good old days using VB6, you had to use windows APIs to do something like this, which was not very simple and required a lot of coding.

The Microsoft .NET Framework has introduced classes like System.IO and System.Diagnostics, which contain the FileSystemWatcher class. This class can raise events when a file is created, renamed, updated or deleted from the specified folder.

In this article we're going to learn how to implement the FileSystemWatcher class using Microsoft Visual Basic.Net. You will need the .NET framework installed, as well as Visual Studio.Net if you want to experiment with the source code presented in this article.

Jayesh Jain is working as a Business Analyst in Auckland, New Zealand. He has several years of n-Tier development experience in developing interactive client solutions. He has a passion for Web development and in the spare time he likes to write articles. Contact him at: jainjayesh74@yahoo.com

Comments

  • Re: Cross-Threading

    Posted by D'Scouser on 06 Feb 2008

    In VB2005 there is a painful cross-threading error that throws an InvalidOperationException when returning text from the fileSystemWatcher to the main form. This can be resolved by ...

  • One way...

    Posted by wduros1 on 04 Dec 2005

    Although the file watcher provides notification of a file create, it provides this notification at the moment of the file "creation", not the moment of the file "completion" if you know what I mean. ...

  • Running this code as a service

    Posted by tlombardi on 26 Sep 2005

    Hi I have tried this code to use it for watching a folder for tif files which I wish to print automatically. I have managed to get it to work in an application mode. However I cant seem to make it wor...

  • Posted by jwillis27640 on 12 Jul 2005

    Thanks JMurDock!! Maybe you can help me with this. I am using Excel 2003 to parse the XML because I don't know what information might be in the file. It has varying field information so I do it like t...

  • Posted by jmurdock on 12 Jul 2005

    [quote][1]Posted by [b]jwillis27640[/b] on 12 Jul 2005 05:14 PM[/1]
    What are you doing with your service? I need the same type of thing but I need to parse the xml and sent it to SQL server. I have d...