![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
|
FileSystemWatcher has multiple paths
Hello all, long time no see. I have a question. I am making a program that uses a FileSystemWatcher. Problem is I need it to watch for than one path or drive. Say someone has two HDD', and they want to watch both of them for activty. How I do that? This is what I got thus far, and it aint working.
Private Sub btnfolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfolder.Click
watcher.Path = lstdrives.CheckedItems.ToString
End SubWhat am I doing wrong? Please help.
__________________
Forgiveness is the fragrance that the violet sheds on the heal that has crushed it. - Mark Twain Destruction leads to a very rough road, but it also breeds creation. |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 852
Rep Power: 4
![]() |
I think you would have to make more than one watcher. It looks form the doco that a FileSystemWatcher can only watch one path (and subdirectories).
|
|
|
|
|
|
#3 |
|
Professional Programmer
|
So like this?
Dim newwatch as New FileSystemWatcher For Each drive in lstdrives.items newwatch Next If so like that. How can I get it to assign each one a path, to make sure that two watchers don't have the same path?
__________________
Forgiveness is the fragrance that the violet sheds on the heal that has crushed it. - Mark Twain Destruction leads to a very rough road, but it also breeds creation. |
|
|
|
|
|
#4 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 852
Rep Power: 4
![]() |
My VB is a bit rusty, but I think you would have to allocate an array (or some other sort of collection) of FileSystemWatcher objects. Then inside a loop, set the watcher[i].path to each item in the list.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| max multiple of 3 | xenop | Software Design and Algorithms | 2 | Nov 7th, 2006 12:28 AM |
| Multiple conditions in an #ifdef statement | JawaKing00 | C | 8 | Apr 26th, 2006 4:11 PM |
| multiple images | Dark Flare Knight | Java | 8 | Jun 15th, 2005 7:19 AM |
| Multiple server clients using sockets + Threads | captainK | Java | 3 | Mar 4th, 2005 10:10 AM |
| multiple definition of variables in include files | carlgreen | C++ | 3 | Feb 26th, 2005 7:02 PM |