OnChange object of FileSystemWatcher not recognized

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

So the question is what should I change it to?
bryan rasmussen [ Mo, 07 Januar 2008 00:32 ] [ ID #1901452 ]

Re: OnChange object of FileSystemWatcher not recognized

"pantagruel" <rasmussen.bryan [at] gmail.com> wrote in message
news:f8c214a8-518f-4cc8-8a4a-60ffb8098c7d [at] v29g2000hsf.google groups.com...
> 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
>
> So the question is what should I change it to?

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.
MR. Arnold [ Mo, 07 Januar 2008 05:31 ] [ ID #1901458 ]

Re: OnChange object of FileSystemWatcher not recognized

On Jan 7, 5:31 am, "Mr. Arnold" <MR. Arn... [at] Arnold.com> wrote:
> "pantagruel" <rasmussen.br... [at] gmail.com> wrote in message
>
> news:f8c214a8-518f-4cc8-8a4a-60ffb8098c7d [at] v29g2000hsf.google groups.com...
>
>
>
> > 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
>
> > So the question is what should I change it to?
>
> 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.

hmm, found the error, I declared the OnChange method incorrectly.
Shouldn't code at midnight in bed.
bryan rasmussen [ Mo, 07 Januar 2008 09:01 ] [ ID #1901466 ]
Microsoft » microsoft.public.dotnet.general » OnChange object of FileSystemWatcher not recognized

Vorheriges Thema: "Automatic" document production
Nächstes Thema: VB.NET Grid related issues