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
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" <simon.segal@mb ox.com.au> wrote in message
news:uNOzo$niDH A.3660@tk2msftn gp13.phx.gbl...[color=blue]
> 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" <nliebel@hotmai l.com> wrote in message
> news:OhZFsgniDH A.2984@TK2MSFTN GP11.phx.gbl...[color=green]
> > 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 |[/color]
> NotifyFilters.L astWrite[color=green]
> > | 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
> >
> >[/color]
>
>[/color]
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" <simon.segal@mb ox.com.au> wrote in message
news:uNOzo$niDH A.3660@tk2msftn gp13.phx.gbl...[color=blue]
> 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" <nliebel@hotmai l.com> wrote in message
> news:OhZFsgniDH A.2984@TK2MSFTN GP11.phx.gbl...[color=green]
> > 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 |[/color]
> NotifyFilters.L astWrite[color=green]
> > | 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
> >
> >[/color]
>
>[/color]