Unknown error....

L

ljh

Here is the code section I am getting an error on

------------------------------------------
'create a watcher for each file type and hook it to the event subs
Dim i As Integer
For i = 0 To UBound(FileTypes) 'FileTypes is a string array with
stuff like "*.doc" in the arrays
ReDim Preserve Watchers(i)
Watchers(i) = New FileSystemWatcher
With Watchers(i)
.Filter = FileTypes(i).ToString
.EnableRaisingEvents = True
.IncludeSubdirectories = True
.InternalBufferSize = 1277592
.NotifyFilter = IO.NotifyFilters.DirectoryName Or
IO.NotifyFilters.LastWrite Or IO.NotifyFilters.FileName Or
IO.NotifyFilters.Size Or IO.NotifyFilters.Attributes

'add handlers
AddHandler Watchers(i).Changed, AddressOf watch_changed
AddHandler Watchers(i).Created, AddressOf watch_changed
AddHandler Watchers(i).Deleted, AddressOf watch_changed
AddHandler Watchers(i).Renamed, AddressOf watch_renamed
End With
Next
------------------------------------------

The error that I get is "The path is not of a legal form." and it points to
the ".EnableRaisingEvents = True" line of code.

The online help is generic and of no use at all.

I don't get it. There is no "path" here. EnableRaisingEvents does not
require a "path" argument only a boolean.

Without this line, no events are triggered and the code is useless.

Can somebody help me figure this one out? PLEEEEEEASE?
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Why do you post VB code in the C# newsgroup? Only post in the relevant
groups, "pleeeeeeeeeeeeeeeeeeeeeeease".

It's much more likely that you are actually getting the error on the
previous line, because you have something in the array that can't be
interpreted as a file mask.
 
L

ljh

Göran Andersson said:
Why do you post VB code in the C# newsgroup? Only post in the relevant
groups, "pleeeeeeeeeeeeeeeeeeeeeeease".

It's much more likely that you are actually getting the error on the
previous line, because you have something in the array that can't be
interpreted as a file mask.

You are right. I had entered ".doc" instead of "*.doc".

And I will try and watch where I post more closely.

Thanks!
 
L

ljh

I spoke too soon.

The error is still there (even with my fix of ".doc" to "*.doc" for the
filter).
 
L

ljh

I falsely thought that FileSystemWatcher would raise events for the whole
SYSTEM (hence the name, right?).

This is not the case.

You must provide a FileSystemWatcher.Path to watch for. This also means
that you must create a File"System"Watcher component for every drive
(physical drives and all networked drives) that you wish to monitor.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top