Array of FileSystem Objects

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • timb

    #1

    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 filesystemobjec ts 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?


  • Neno Loje [MSP]

    #2
    Re: Array of FileSystem Objects

    Hi "timb",

    (maybe you could write your full name here)

    You can store your FileSystemWatch er 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();
    ....
    FileSystemWatch er newWatcher = new FileSystemWatch er();
    newWatcher.Chan ged += new FileSystemEvent Handler(OnChang ed);
    myWatchers.Add( newWatcher);
    ....
    private void OnChanged(objec t sender, FileSystemEvent Args e)
    {
    // Add the code for the changed event here.
    }

    Hope it helps,

    Neno Loje
    Microsoft Student Partner
    University of Hamburg


    Comment

    Working...