OnChange object of FileSystemWatcher not recognized
am 07.01.2008 00:32:20 von bryan rasmussen
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?
Re: OnChange object of FileSystemWatcher not recognized
am 07.01.2008 05:31:40 von MR. Arnold
"pantagruel" wrote in message
news:f8c214a8-518f-4cc8-8a4a-60ffb8098c7d@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.
Re: OnChange object of FileSystemWatcher not recognized
am 07.01.2008 09:01:55 von bryan rasmussen
On Jan 7, 5:31 am, "Mr. Arnold" wrote:
> "pantagruel" wrote in message
>
> news:f8c214a8-518f-4cc8-8a4a-60ffb8098c7d@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.