473,836 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RaiseEvent in csharp

How do I do a RaiseEvent in csharp
I'm ok in VB but csharp confused me a lot.

******* code ********
private FileSystemWatch er watcher = new FileSystemWatch er();

public delegate void Changed(Watcher ChangeTypes exch);
public delegate void Created(string fileName);
public delegate void ReCreated(strin g OldName, string newName);
public delegate void OverRun(string Message);

public FileWatcher()
{
watcher.Path = "C:\\";

//* Watch for changes in LastAccess and LastWrite times, and
// the renaming of files or directories. */
watcher.NotifyF ilter = NotifyFilters.L astAccess | NotifyFilters.L astWrite
| NotifyFilters.F ileName | NotifyFilters.D irectoryName;

// Only watch text files.
watcher.Filter = "*.txt";

// Add event handlers.
watcher.Changed += new FileSystemEvent Handler(OnChang ed);
watcher.Created += new FileSystemEvent Handler(OnCreat ed);
watcher.Deleted += new FileSystemEvent Handler(OnChang ed);
watcher.Renamed += new RenamedEventHan dler(OnRenamed) ;
watcher.Error += new ErrorEventHandl er(OnError);

// Begin watching.
watcher.EnableR aisingEvents = true;

}

protected virtual void OnChanged(objec t sender, FileSystemEvent Args e)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//Changed(e.Chang eType);
}

protected virtual void OnCreated(objec t sender, FileSystemEvent Args e)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//RaiseEvent Created(e.FullP ath);
}

protected virtual void OnRenamed(objec t sender , RenamedEventArg s a)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//RaiseEvent ReCreated(e.Old FullPath, e.FullPath);
}

Thank you
Nov 15 '05 #1
8 10107
awk
You havent declared an event of type one of your delegates in your code.

eg
public event Changed FileWatcherChan ged;

and you raise this

protected virtual void OnChanged(objec t sender, FileSystemEvent Args e)
{
changed(e.Chang eType);
}

Regards,

A

"Nicolas" <nl*****@hotmai l.com> wrote in message
news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
How do I do a RaiseEvent in csharp
I'm ok in VB but csharp confused me a lot.

******* code ********
private FileSystemWatch er watcher = new FileSystemWatch er();

public delegate void Changed(Watcher ChangeTypes exch);
public delegate void Created(string fileName);
public delegate void ReCreated(strin g OldName, string newName);
public delegate void OverRun(string Message);

public FileWatcher()
{
watcher.Path = "C:\\";

//* Watch for changes in LastAccess and LastWrite times, and
// the renaming of files or directories. */
watcher.NotifyF ilter = NotifyFilters.L astAccess | NotifyFilters.L astWrite | NotifyFilters.F ileName | NotifyFilters.D irectoryName;

// Only watch text files.
watcher.Filter = "*.txt";

// Add event handlers.
watcher.Changed += new FileSystemEvent Handler(OnChang ed);
watcher.Created += new FileSystemEvent Handler(OnCreat ed);
watcher.Deleted += new FileSystemEvent Handler(OnChang ed);
watcher.Renamed += new RenamedEventHan dler(OnRenamed) ;
watcher.Error += new ErrorEventHandl er(OnError);

// Begin watching.
watcher.EnableR aisingEvents = true;

}

protected virtual void OnChanged(objec t sender, FileSystemEvent Args e)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//Changed(e.Chang eType);
}

protected virtual void OnCreated(objec t sender, FileSystemEvent Args e)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//RaiseEvent Created(e.FullP ath);
}

protected virtual void OnRenamed(objec t sender , RenamedEventArg s a)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//RaiseEvent ReCreated(e.Old FullPath, e.FullPath);
}

Thank you

Nov 15 '05 #2
awk
You havent declared an event of type one of your delegates in your code.

eg
public event Changed FileWatcherChan ged;

and you raise this

protected virtual void OnChanged(objec t sender, FileSystemEvent Args e)
{
changed(e.Chang eType);
}

Regards,

A

"Nicolas" <nl*****@hotmai l.com> wrote in message
news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
How do I do a RaiseEvent in csharp
I'm ok in VB but csharp confused me a lot.

******* code ********
private FileSystemWatch er watcher = new FileSystemWatch er();

public delegate void Changed(Watcher ChangeTypes exch);
public delegate void Created(string fileName);
public delegate void ReCreated(strin g OldName, string newName);
public delegate void OverRun(string Message);

public FileWatcher()
{
watcher.Path = "C:\\";

//* Watch for changes in LastAccess and LastWrite times, and
// the renaming of files or directories. */
watcher.NotifyF ilter = NotifyFilters.L astAccess | NotifyFilters.L astWrite | NotifyFilters.F ileName | NotifyFilters.D irectoryName;

// Only watch text files.
watcher.Filter = "*.txt";

// Add event handlers.
watcher.Changed += new FileSystemEvent Handler(OnChang ed);
watcher.Created += new FileSystemEvent Handler(OnCreat ed);
watcher.Deleted += new FileSystemEvent Handler(OnChang ed);
watcher.Renamed += new RenamedEventHan dler(OnRenamed) ;
watcher.Error += new ErrorEventHandl er(OnError);

// Begin watching.
watcher.EnableR aisingEvents = true;

}

protected virtual void OnChanged(objec t sender, FileSystemEvent Args e)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//Changed(e.Chang eType);
}

protected virtual void OnCreated(objec t sender, FileSystemEvent Args e)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//RaiseEvent Created(e.FullP ath);
}

protected virtual void OnRenamed(objec t sender , RenamedEventArg s a)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//RaiseEvent ReCreated(e.Old FullPath, e.FullPath);
}

Thank you

Nov 15 '05 #3
Thanks, but now how do I call those functions from another form as all this
is in a dll now.

This is what I had in VB
////////////////// CODE \\\\\\\\\\\\\\\ \\\\\
Imports it

Dim fw As New it_FileWatcher. FileWatcher()

AddHandler fw.Changed, AddressOf onChange

Sub onChange(ByVal changeType As System.IO.Watch erChangeTypes, ByVal
filename As String)

System.Diagnost ics.Process.Sta rt(filename)

End Sub

what should I do to get the same in csharp???

Thank you very much for the help.

"awk" <si*********@mb ox.com.au> wrote in message
news:uN******** ******@tk2msftn gp13.phx.gbl...
You havent declared an event of type one of your delegates in your code.

eg
public event Changed FileWatcherChan ged;

and you raise this

protected virtual void OnChanged(objec t sender, FileSystemEvent Args e)
{
changed(e.Chang eType);
}

Regards,

A

"Nicolas" <nl*****@hotmai l.com> wrote in message
news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
How do I do a RaiseEvent in csharp
I'm ok in VB but csharp confused me a lot.

******* code ********
private FileSystemWatch er watcher = new FileSystemWatch er();

public delegate void Changed(Watcher ChangeTypes exch);
public delegate void Created(string fileName);
public delegate void ReCreated(strin g OldName, string newName);
public delegate void OverRun(string Message);

public FileWatcher()
{
watcher.Path = "C:\\";

//* Watch for changes in LastAccess and LastWrite times, and
// the renaming of files or directories. */
watcher.NotifyF ilter = NotifyFilters.L astAccess |

NotifyFilters.L astWrite
| NotifyFilters.F ileName | NotifyFilters.D irectoryName;

// Only watch text files.
watcher.Filter = "*.txt";

// Add event handlers.
watcher.Changed += new FileSystemEvent Handler(OnChang ed);
watcher.Created += new FileSystemEvent Handler(OnCreat ed);
watcher.Deleted += new FileSystemEvent Handler(OnChang ed);
watcher.Renamed += new RenamedEventHan dler(OnRenamed) ;
watcher.Error += new ErrorEventHandl er(OnError);

// Begin watching.
watcher.EnableR aisingEvents = true;

}

protected virtual void OnChanged(objec t sender, FileSystemEvent Args e)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//Changed(e.Chang eType);
}

protected virtual void OnCreated(objec t sender, FileSystemEvent Args e)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//RaiseEvent Created(e.FullP ath);
}

protected virtual void OnRenamed(objec t sender , RenamedEventArg s a)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//RaiseEvent ReCreated(e.Old FullPath, e.FullPath);
}

Thank you


Nov 15 '05 #4
Thanks, but now how do I call those functions from another form as all this
is in a dll now.

This is what I had in VB
////////////////// CODE \\\\\\\\\\\\\\\ \\\\\
Imports it

Dim fw As New it_FileWatcher. FileWatcher()

AddHandler fw.Changed, AddressOf onChange

Sub onChange(ByVal changeType As System.IO.Watch erChangeTypes, ByVal
filename As String)

System.Diagnost ics.Process.Sta rt(filename)

End Sub

what should I do to get the same in csharp???

Thank you very much for the help.

"awk" <si*********@mb ox.com.au> wrote in message
news:uN******** ******@tk2msftn gp13.phx.gbl...
You havent declared an event of type one of your delegates in your code.

eg
public event Changed FileWatcherChan ged;

and you raise this

protected virtual void OnChanged(objec t sender, FileSystemEvent Args e)
{
changed(e.Chang eType);
}

Regards,

A

"Nicolas" <nl*****@hotmai l.com> wrote in message
news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
How do I do a RaiseEvent in csharp
I'm ok in VB but csharp confused me a lot.

******* code ********
private FileSystemWatch er watcher = new FileSystemWatch er();

public delegate void Changed(Watcher ChangeTypes exch);
public delegate void Created(string fileName);
public delegate void ReCreated(strin g OldName, string newName);
public delegate void OverRun(string Message);

public FileWatcher()
{
watcher.Path = "C:\\";

//* Watch for changes in LastAccess and LastWrite times, and
// the renaming of files or directories. */
watcher.NotifyF ilter = NotifyFilters.L astAccess |

NotifyFilters.L astWrite
| NotifyFilters.F ileName | NotifyFilters.D irectoryName;

// Only watch text files.
watcher.Filter = "*.txt";

// Add event handlers.
watcher.Changed += new FileSystemEvent Handler(OnChang ed);
watcher.Created += new FileSystemEvent Handler(OnCreat ed);
watcher.Deleted += new FileSystemEvent Handler(OnChang ed);
watcher.Renamed += new RenamedEventHan dler(OnRenamed) ;
watcher.Error += new ErrorEventHandl er(OnError);

// Begin watching.
watcher.EnableR aisingEvents = true;

}

protected virtual void OnChanged(objec t sender, FileSystemEvent Args e)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//Changed(e.Chang eType);
}

protected virtual void OnCreated(objec t sender, FileSystemEvent Args e)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//RaiseEvent Created(e.FullP ath);
}

protected virtual void OnRenamed(objec t sender , RenamedEventArg s a)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK
\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//RaiseEvent ReCreated(e.Old FullPath, e.FullPath);
}

Thank you


Nov 15 '05 #5
awk
Hi Nicolas

I think this is what your after.

it_FileWatcher. FileWatcher fw = new it_FileWatcher. FileWatcher();
fw.Changed += new it_FileWatcher. Changed(onChang e);

private void onChange(System .IO.WatcherChan geTypes change, string filename)
{
System.Diagnost ics.Process.Sta rt(filename);
}

For more info check these out.

this link for some detail delegate and event coding in c#
with vb equivelants for comparison
http://codeproject.com/dotnet/observerlistview.asp

and

http://www.thecodeproject.com/csharp...te_bedtime.asp

Simon

"Nicolas" <nl*****@hotmai l.com> wrote in message
news:uR******** *****@tk2msftng p13.phx.gbl...
Thanks, but now how do I call those functions from another form as all this is in a dll now.

This is what I had in VB
////////////////// CODE \\\\\\\\\\\\\\\ \\\\\
Imports it

Dim fw As New it_FileWatcher. FileWatcher()

AddHandler fw.Changed, AddressOf onChange

Sub onChange(ByVal changeType As System.IO.Watch erChangeTypes, ByVal
filename As String)

System.Diagnost ics.Process.Sta rt(filename)

End Sub

what should I do to get the same in csharp???

Thank you very much for the help.

"awk" <si*********@mb ox.com.au> wrote in message
news:uN******** ******@tk2msftn gp13.phx.gbl...
You havent declared an event of type one of your delegates in your code.
eg
public event Changed FileWatcherChan ged;

and you raise this

protected virtual void OnChanged(objec t sender, FileSystemEvent Args e)
{
changed(e.Chang eType);
}

Regards,

A

"Nicolas" <nl*****@hotmai l.com> wrote in message
news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
How do I do a RaiseEvent in csharp
I'm ok in VB but csharp confused me a lot.

******* code ********
private FileSystemWatch er watcher = new FileSystemWatch er();

public delegate void Changed(Watcher ChangeTypes exch);
public delegate void Created(string fileName);
public delegate void ReCreated(strin g OldName, string newName);
public delegate void OverRun(string Message);

public FileWatcher()
{
watcher.Path = "C:\\";

//* Watch for changes in LastAccess and LastWrite times, and
// the renaming of files or directories. */
watcher.NotifyF ilter = NotifyFilters.L astAccess |

NotifyFilters.L astWrite
| NotifyFilters.F ileName | NotifyFilters.D irectoryName;

// Only watch text files.
watcher.Filter = "*.txt";

// Add event handlers.
watcher.Changed += new FileSystemEvent Handler(OnChang ed);
watcher.Created += new FileSystemEvent Handler(OnCreat ed);
watcher.Deleted += new FileSystemEvent Handler(OnChang ed);
watcher.Renamed += new RenamedEventHan dler(OnRenamed) ;
watcher.Error += new ErrorEventHandl er(OnError);

// Begin watching.
watcher.EnableR aisingEvents = true;

}

protected virtual void OnChanged(objec t sender, FileSystemEvent Args e) {
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//Changed(e.Chang eType);
}

protected virtual void OnCreated(objec t sender, FileSystemEvent Args e)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//RaiseEvent Created(e.FullP ath);
}

protected virtual void OnRenamed(objec t sender , RenamedEventArg s a)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//RaiseEvent ReCreated(e.Old FullPath, e.FullPath);
}

Thank you



Nov 15 '05 #6
awk
Hi Nicolas

I think this is what your after.

it_FileWatcher. FileWatcher fw = new it_FileWatcher. FileWatcher();
fw.Changed += new it_FileWatcher. Changed(onChang e);

private void onChange(System .IO.WatcherChan geTypes change, string filename)
{
System.Diagnost ics.Process.Sta rt(filename);
}

For more info check these out.

this link for some detail delegate and event coding in c#
with vb equivelants for comparison
http://codeproject.com/dotnet/observerlistview.asp

and

http://www.thecodeproject.com/csharp...te_bedtime.asp

Simon

"Nicolas" <nl*****@hotmai l.com> wrote in message
news:uR******** *****@tk2msftng p13.phx.gbl...
Thanks, but now how do I call those functions from another form as all this is in a dll now.

This is what I had in VB
////////////////// CODE \\\\\\\\\\\\\\\ \\\\\
Imports it

Dim fw As New it_FileWatcher. FileWatcher()

AddHandler fw.Changed, AddressOf onChange

Sub onChange(ByVal changeType As System.IO.Watch erChangeTypes, ByVal
filename As String)

System.Diagnost ics.Process.Sta rt(filename)

End Sub

what should I do to get the same in csharp???

Thank you very much for the help.

"awk" <si*********@mb ox.com.au> wrote in message
news:uN******** ******@tk2msftn gp13.phx.gbl...
You havent declared an event of type one of your delegates in your code.
eg
public event Changed FileWatcherChan ged;

and you raise this

protected virtual void OnChanged(objec t sender, FileSystemEvent Args e)
{
changed(e.Chang eType);
}

Regards,

A

"Nicolas" <nl*****@hotmai l.com> wrote in message
news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
How do I do a RaiseEvent in csharp
I'm ok in VB but csharp confused me a lot.

******* code ********
private FileSystemWatch er watcher = new FileSystemWatch er();

public delegate void Changed(Watcher ChangeTypes exch);
public delegate void Created(string fileName);
public delegate void ReCreated(strin g OldName, string newName);
public delegate void OverRun(string Message);

public FileWatcher()
{
watcher.Path = "C:\\";

//* Watch for changes in LastAccess and LastWrite times, and
// the renaming of files or directories. */
watcher.NotifyF ilter = NotifyFilters.L astAccess |

NotifyFilters.L astWrite
| NotifyFilters.F ileName | NotifyFilters.D irectoryName;

// Only watch text files.
watcher.Filter = "*.txt";

// Add event handlers.
watcher.Changed += new FileSystemEvent Handler(OnChang ed);
watcher.Created += new FileSystemEvent Handler(OnCreat ed);
watcher.Deleted += new FileSystemEvent Handler(OnChang ed);
watcher.Renamed += new RenamedEventHan dler(OnRenamed) ;
watcher.Error += new ErrorEventHandl er(OnError);

// Begin watching.
watcher.EnableR aisingEvents = true;

}

protected virtual void OnChanged(objec t sender, FileSystemEvent Args e) {
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//Changed(e.Chang eType);
}

protected virtual void OnCreated(objec t sender, FileSystemEvent Args e)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//RaiseEvent Created(e.FullP ath);
}

protected virtual void OnRenamed(objec t sender , RenamedEventArg s a)
{
///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
//RaiseEvent ReCreated(e.Old FullPath, e.FullPath);
}

Thank you



Nov 15 '05 #7
Thank a lot , work ok now!!!
"awk" <si*********@mb ox.com.au> wrote in message
news:u9******** ******@TK2MSFTN GP10.phx.gbl...
Hi Nicolas

I think this is what your after.

it_FileWatcher. FileWatcher fw = new it_FileWatcher. FileWatcher();
fw.Changed += new it_FileWatcher. Changed(onChang e);

private void onChange(System .IO.WatcherChan geTypes change, string filename) {
System.Diagnost ics.Process.Sta rt(filename);
}

For more info check these out.

this link for some detail delegate and event coding in c#
with vb equivelants for comparison
http://codeproject.com/dotnet/observerlistview.asp

and

http://www.thecodeproject.com/csharp...te_bedtime.asp

Simon

"Nicolas" <nl*****@hotmai l.com> wrote in message
news:uR******** *****@tk2msftng p13.phx.gbl...
Thanks, but now how do I call those functions from another form as all this
is in a dll now.

This is what I had in VB
////////////////// CODE \\\\\\\\\\\\\\\ \\\\\
Imports it

Dim fw As New it_FileWatcher. FileWatcher()

AddHandler fw.Changed, AddressOf onChange

Sub onChange(ByVal changeType As System.IO.Watch erChangeTypes, ByVal
filename As String)

System.Diagnost ics.Process.Sta rt(filename)

End Sub

what should I do to get the same in csharp???

Thank you very much for the help.

"awk" <si*********@mb ox.com.au> wrote in message
news:uN******** ******@tk2msftn gp13.phx.gbl...
You havent declared an event of type one of your delegates in your code.
eg
public event Changed FileWatcherChan ged;

and you raise this

protected virtual void OnChanged(objec t sender, FileSystemEvent Args e)
{
changed(e.Chang eType);
}

Regards,

A

"Nicolas" <nl*****@hotmai l.com> wrote in message
news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
> How do I do a RaiseEvent in csharp
> I'm ok in VB but csharp confused me a lot.
>
> ******* code ********
> private FileSystemWatch er watcher = new FileSystemWatch er();
>
> public delegate void Changed(Watcher ChangeTypes exch);
> public delegate void Created(string fileName);
> public delegate void ReCreated(strin g OldName, string newName);
> public delegate void OverRun(string Message);
>
> public FileWatcher()
> {
> watcher.Path = "C:\\";
>
> //* Watch for changes in LastAccess and LastWrite times, and
> // the renaming of files or directories. */
> watcher.NotifyF ilter = NotifyFilters.L astAccess |
NotifyFilters.L astWrite
> | NotifyFilters.F ileName | NotifyFilters.D irectoryName;
>
> // Only watch text files.
> watcher.Filter = "*.txt";
>
> // Add event handlers.
> watcher.Changed += new FileSystemEvent Handler(OnChang ed);
> watcher.Created += new FileSystemEvent Handler(OnCreat ed);
> watcher.Deleted += new FileSystemEvent Handler(OnChang ed);
> watcher.Renamed += new RenamedEventHan dler(OnRenamed) ;
> watcher.Error += new ErrorEventHandl er(OnError);
>
> // Begin watching.
> watcher.EnableR aisingEvents = true;
>
> }
>
> protected virtual void OnChanged(objec t sender, FileSystemEvent Args e)
> {
> ///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
> //Changed(e.Chang eType);
> }
>
> protected virtual void OnCreated(objec t sender, FileSystemEvent Args
e) > {
> ///////////////////////////////////////// THIS IS WHERE IT DOESN'T

WORK > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
> //RaiseEvent Created(e.FullP ath);
> }
>
> protected virtual void OnRenamed(objec t sender , RenamedEventArg s a) > {
> ///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
> //RaiseEvent ReCreated(e.Old FullPath, e.FullPath);
> }
>
>
>
> Thank you
>
>



Nov 15 '05 #8
Thank a lot , work ok now!!!
"awk" <si*********@mb ox.com.au> wrote in message
news:u9******** ******@TK2MSFTN GP10.phx.gbl...
Hi Nicolas

I think this is what your after.

it_FileWatcher. FileWatcher fw = new it_FileWatcher. FileWatcher();
fw.Changed += new it_FileWatcher. Changed(onChang e);

private void onChange(System .IO.WatcherChan geTypes change, string filename) {
System.Diagnost ics.Process.Sta rt(filename);
}

For more info check these out.

this link for some detail delegate and event coding in c#
with vb equivelants for comparison
http://codeproject.com/dotnet/observerlistview.asp

and

http://www.thecodeproject.com/csharp...te_bedtime.asp

Simon

"Nicolas" <nl*****@hotmai l.com> wrote in message
news:uR******** *****@tk2msftng p13.phx.gbl...
Thanks, but now how do I call those functions from another form as all this
is in a dll now.

This is what I had in VB
////////////////// CODE \\\\\\\\\\\\\\\ \\\\\
Imports it

Dim fw As New it_FileWatcher. FileWatcher()

AddHandler fw.Changed, AddressOf onChange

Sub onChange(ByVal changeType As System.IO.Watch erChangeTypes, ByVal
filename As String)

System.Diagnost ics.Process.Sta rt(filename)

End Sub

what should I do to get the same in csharp???

Thank you very much for the help.

"awk" <si*********@mb ox.com.au> wrote in message
news:uN******** ******@tk2msftn gp13.phx.gbl...
You havent declared an event of type one of your delegates in your code.
eg
public event Changed FileWatcherChan ged;

and you raise this

protected virtual void OnChanged(objec t sender, FileSystemEvent Args e)
{
changed(e.Chang eType);
}

Regards,

A

"Nicolas" <nl*****@hotmai l.com> wrote in message
news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
> How do I do a RaiseEvent in csharp
> I'm ok in VB but csharp confused me a lot.
>
> ******* code ********
> private FileSystemWatch er watcher = new FileSystemWatch er();
>
> public delegate void Changed(Watcher ChangeTypes exch);
> public delegate void Created(string fileName);
> public delegate void ReCreated(strin g OldName, string newName);
> public delegate void OverRun(string Message);
>
> public FileWatcher()
> {
> watcher.Path = "C:\\";
>
> //* Watch for changes in LastAccess and LastWrite times, and
> // the renaming of files or directories. */
> watcher.NotifyF ilter = NotifyFilters.L astAccess |
NotifyFilters.L astWrite
> | NotifyFilters.F ileName | NotifyFilters.D irectoryName;
>
> // Only watch text files.
> watcher.Filter = "*.txt";
>
> // Add event handlers.
> watcher.Changed += new FileSystemEvent Handler(OnChang ed);
> watcher.Created += new FileSystemEvent Handler(OnCreat ed);
> watcher.Deleted += new FileSystemEvent Handler(OnChang ed);
> watcher.Renamed += new RenamedEventHan dler(OnRenamed) ;
> watcher.Error += new ErrorEventHandl er(OnError);
>
> // Begin watching.
> watcher.EnableR aisingEvents = true;
>
> }
>
> protected virtual void OnChanged(objec t sender, FileSystemEvent Args e)
> {
> ///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
> //Changed(e.Chang eType);
> }
>
> protected virtual void OnCreated(objec t sender, FileSystemEvent Args
e) > {
> ///////////////////////////////////////// THIS IS WHERE IT DOESN'T

WORK > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
> //RaiseEvent Created(e.FullP ath);
> }
>
> protected virtual void OnRenamed(objec t sender , RenamedEventArg s a) > {
> ///////////////////////////////////////// THIS IS WHERE IT DOESN'T WORK > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
> //RaiseEvent ReCreated(e.Old FullPath, e.FullPath);
> }
>
>
>
> Thank you
>
>



Nov 15 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1641
by: Guille | last post by:
Hi all! I'm having some weird behaviour in a .NET application i'm developing. I'll try to explain: I've created a Class that wraps an asynchronous socket. When connect callback is called, i raise a class event : ' Create socket sock = New Socket(AddressFamily.InterNetwork, _
0
501
by: Nicolas | last post by:
How do I call those functions from another form This is what I had in VB ////////////////// CODE \\\\\\\\\\\\\\\\\\\\ Imports it Dim fw As New it_FileWatcher.FileWatcher() AddHandler fw.Changed, AddressOf onChange
6
54457
by: shachar | last post by:
hi all. in vb.net i can write RaiseEvent. can i do it in C# also? how? thanks - shachar.
2
6808
by: Carl tam | last post by:
Hi everyone, I got a quite interesting problem myself and got stuck. I have an aspx page with a windows user control with it. in the Windows Control. I have a RaiseEvent statement, say OnClearAlarm, and tell the computer to RaiseEvent when I click on the Panel. in the webpage, I first load the user control, and then have a javascript function to handle the event:
2
1442
by: Lim | last post by:
I've developed a program that raise an event. This program works fine on a Windows 2000 Professional PC. However when I try to run the program on a Windos XP Professional PC, the program will not execute the raiseevent function. How can I resolve the problem?
2
2009
by: dmoonme | last post by:
I'm trying to rename some files in a directory. Pretty basic stuff - renaming the files works fine but the problem I have is updated the text in textbox. All I want to do is appendtext to a textbox. The problem is that duplicate text occurs. Hopefully my code will explain better what I'm trying to do and what i'm doing wrong :) Thanks for your help! Public Class Form1 Private Sub btnRun_Click(ByVal sender As System.Object, ByVal e...
3
1770
by: Martin | last post by:
Hi all, I'm having a problem when trying to raise an event in my custom control when a toolstripbutton enable state changes. The problem is that although the code to raise the event executes, my handler never see it. This executes when the button enable state changes:- Private Sub OnPrintToolStripButton_EnabledChanged(ByVal sender As Object, ByVal e As System.EventArgs)Handles PrintToolStripButton.EnabledChanged
1
2059
by: Terry Olsen | last post by:
I have a program with a couple of long running processes that i'm calling on a separate thread. When the process is completed, I want to raise an event to tell the main thread that it's done. I set it up this way... Public Class frmLongRunningProcess Public Enum Proc ParseZipFiles = 0
10
6758
by: hzgt9b | last post by:
Using VS2005, VB.NET, I am developing a windows app. The application opens a couple of forms. While the forms are open I want to raise some events, such as logging errors - but I call RaiseEvent, nothing happens. Below are some code snippets that show what I am doing. Can someone straighten me out... I feel like this must be something real simple... '------------------------------------------------------------------------------ Public...
0
9670
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10548
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10591
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7792
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6979
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4452
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3115
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.