HI RA,
First of all SetInfo will not compile cause you are not returning an
integer.
You cannot call it unless you make it static, or if you make the watcher
handler not static.
The only way that you dont have to change the declarations is if you
include a reference to the class itself as a static member:
class MyClass
{
static MyClass reference;
....
}
and then in the constructor you assign it:
public MyClass ()
{
reference = this;
}
then you can call the instance method using reference.SetInfo( ... )
Nevertheless, I think that you should not do this, if SetInfo is independend
of the instance you should make it a static member.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"R.A." <te**@citsecure.com> wrote in message
news:eJ**************@TK2MSFTNGP09.phx.gbl...
Hi
I have th following code:
class MyClass
{
private string filename;
public int SetInfo (string FileName)
{
filename = FileName;
}
public MyClass ()
{
FileWatcher = new FileSystemWatcher ();
FileWatcher.NotifyFilter = NotifyFilters.FileName;
FileWatcher.Filter = "*.*";
FileWatcher.Path = "C:\\temp";
FileWatcher.Created += new FileSystemEventHandler (OnFileCreated);
}
private static void OnFileCreated(object source, FileSystemEventArgs e)
{
//How to call SetInfo ?
}
}
How can I call SetInfo without having to change it to a static function?
What are the options?
Thanks