all groups > dotnet general > january 2008 >
You're in the

dotnet general

group:

OnChange object of FileSystemWatcher not recognized



OnChange object of FileSystemWatcher not recognized pantagruel
1/6/2008 3:32:20 PM
dotnet general: The following code:

FileSystemWatcher watcher = new FileSystemWatcher();
RenderingQ =
ConfigurationSettings.AppSettings["RenderingQ"];
watcher.Path = RenderingQ;
watcher.NotifyFilter = NotifyFilters.LastWrite;
watcher.Filter = "*.txt";

// Add event handlers.

watcher.Created += new FileSystemEventHandler(OnChanged);


// Begin watching.
watcher.EnableRaisingEvents = true;
raises the following error:

The name 'OnChanged' does not exist in the current context

Re: OnChange object of FileSystemWatcher not recognized Mr. Arnold
1/6/2008 11:31:40 PM

[quoted text, click to view]

You make a method called OnChange so the event is pointing to it. You had
best find out the signature of that particular event, so that the correct
Event Args are passed to the function you need to make manually. Or you can
drop a FileSystemWatch on the form, go to Properties, the Event icon (the
Lightening bolt), Change and give it a name called OnChange to see what is
put there for the code.

You might want to do a GO TO on the InitializeComponent() to see what it put
there for the Control because your += new doesn't look right.
Re: OnChange object of FileSystemWatcher not recognized pantagruel
1/7/2008 12:01:55 AM
[quoted text, click to view]

hmm, found the error, I declared the OnChange method incorrectly.
Shouldn't code at midnight in bed.
AddThis Social Bookmark Button