473,406 Members | 2,713 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,406 software developers and data experts.

Array of FileSystem Objects

Hi,
i want to declare an array of file system watcher objects. The idea is
that my config file specifies how many directories to monitor and then i
dynamically declare the filesystemobjects and add them to an array. This
idea was so i can create a event for handling these events since i dont know
how many there are at design time and therefore cannot create the stub code.
Does anyone have any examples of such use of arrays?
Nov 15 '05 #1
1 1340
Hi "timb",

(maybe you could write your full name here)

You can store your FileSystemWatcher Objects in an ArrayList for example.
Before adding it to the collection you should attach to the events you need,
like this:

ArrayList myWatchers = new ArrayList();
....
FileSystemWatcher newWatcher = new FileSystemWatcher();
newWatcher.Changed += new FileSystemEventHandler(OnChanged);
myWatchers.Add(newWatcher);
....
private void OnChanged(object sender, FileSystemEventArgs e)
{
// Add the code for the changed event here.
}

Hope it helps,

Neno Loje
Microsoft Student Partner
University of Hamburg
Nov 15 '05 #2

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

Similar topics

3
by: Shaun Merrill | last post by:
Hey, here is my code. I am trying to read a file into a byte array. Please show me how this can work. Obviously I need to read into a dynamic array because it could read any file. So why does...
2
by: Joolz | last post by:
Hello everyone, Sorry if this is a FAQ, but I've groups.googled the subject and can't find a definite answer (if such a thing exists). I'm working on a db in postgresql on a debian stable...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
7
by: =?Utf-8?B?YmVyaWNr?= | last post by:
New to this, I used to pass an array like this function BytesToString(byref myarray() as byte, somethingelse as long) as long and m = BytesToString(fooBar(), bluenose) This would send...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.