473,473 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 5548
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.