473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

FileSystemWatcher example

Does anyone have an example of how to use this object

Basically, I want to check for changes in a directory automatically and if their are changes to it (ie FTP) then I want the system to auto upload to the database

But I need an example to get starte

Thank

Adam

Nov 16 '05 #1
1 5547
Here's an example that fires an event whenever a file is added to the
specified folder.

// folder to watch
FileSystemWatcher theWatcher = new FileSystemWatcher(@"e:\WatchThisFolder");

// type of change to watch for
theWatcher.NotifyFilter = NotifyFilters.FileName;

// delegate to handle the event
theWatcher.Created += new FileSystemEventHandler(this.OnFolderChanged);

// begin watching
theWatcher.EnableRaisingEvents = true;

// delegate method to handle the Created event of the FSW
// just output the name of the file to the debugger
void OnFolderChanged(object o, FileSystemEventArgs e)
{
System.Diagnostics.Debug.WriteLine(e.Name);
}

Check out
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemiofilesystemwatcherclasstopic.asp for addional information.

hth

-Joel
--------------------
Thread-Topic: FileSystemWatcher example
thread-index: AcQcr7+ifwN/E1cKT1Ca9CVI1YH46A==
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
From: "=?Utf-8?B?QWRhbUQ=?=" <an*******@discussions.microsoft.com>
Subject: FileSystemWatcher example
Date: Wed, 7 Apr 2004 07:51:03 -0700
Lines: 10
Message-ID: <BE**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.languages.csharp
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:235887
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Does anyone have an example of how to use this object.
Basically, I want to check for changes in a directory automatically and if
their are changes to it (ie FTP) then I want the system to auto upload to
the database.

But I need an example to get started

Thanks

AdamD

--------------------------------------------------------------------
This reply is provided AS IS, without warranty (express or implied).
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: AdamD | last post by:
Does anyone have an example of how to use this object Basically, I want to check for changes in a directory automatically and if their are changes to it (ie FTP) then I want the system to auto...
2
by: Jet Leung | last post by:
Hi all, I had made a program to watching files in my directory. I had used a instance of FileSystemWatcher to do my work.And I had add some events of the FileSystemWatcher , for example onChange,...
13
by: David | last post by:
I have been working on trying to write a directory watcher service. One of the requirments is that it be able to watch multiple directories, not sub directories of one parent directory, but just...
3
by: Stampede | last post by:
Hi, I write an application which waits for incomming files in a specified directory. I thought, that using the FileSystemWatcher would be the best, as it does exactly what I need. But now I have...
20
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business...
2
by: kmcnet | last post by:
Hello Everyone and thanks for your help in advance. I have been battling a problem for nearly a month with the FileSystemWatcher component. Basically, what I am trying to do it to monitor three...
9
by: Tushar | last post by:
Followup-To: microsoft.public.dotnet.general Does anyone know when is this event raised, is it: 1) When the file is created but may not have been closed 2) When the file is created AND it has...
1
by: Abel Chan | last post by:
Hi there, I was trying to write a simple NT services using .NET 2.0 and fileSystemWatcher control. The goal is to poll documents from a watch directory and ftp them to a remote web site. I...
5
by: =?Utf-8?B?Sm9obiBT?= | last post by:
I am trying to find out if there is a way to tell if there is already a filesystemwatcher (created by a webservice) monitoring a folder. I have a webservice that creates a filesystemwatcher,...
2
by: Soulless | last post by:
Hi, I implemented the FileSystemWatcher in an application and on my XP system it works fine. If I add a file to a directory, it will enable a button and disable if removed. On another XP system...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.