C# FileSystemWatcher Problem

  • Thread starter Thread starter eyal
  • Start date Start date
E

eyal

Hi,

I'm trying to do this:

private void SetNF(FileSystemWatcher fsw,int val){
if( (val&4)!=0 )
fsw.NotifyFilter |= System.IO.NotifyFilters.Attributes;
// i'v tried this also:
// if( (val&4)!=0 )
fsw.NotifyFilter = System.IO.NotifyFilters.Attributes;
}

and i get this EXCEPTION:
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll

Additional information: The path is not of a legal form.


Please Help.
 
Try this

//I assume you want to add this new filter to your existing filters on
// the fileSystemWatcher
private void SetNF(FileSystemWatcher fsw, NotifyFilters filter)
{
fsw.NotifyFilter |= filter;
}

Let me know if this is not what you are trying to do, note that to check
if a filter has been set in the FSW the code would be as below

For e.g. if you want to check if the attribute filter is set

if( (fsw.NotifyFilter & NotifyFilters.Attribute) == NotifyFilters.Attribute)
attributeFilterSet = true;
else
attributeFilterSet = false;

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
 
Back
Top