RaiseEvent in csharp

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nicolas

    #1

    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


  • awk

    #2
    Re: RaiseEvent in csharp

    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=blue]
    > 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=blue]
    > | 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]


    Comment

    • awk

      #3
      Re: RaiseEvent in csharp

      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=blue]
      > 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=blue]
      > | 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]


      Comment

      • Nicolas

        #4
        Re: RaiseEvent in csharp

        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" <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]


        Comment

        • Nicolas

          #5
          Re: RaiseEvent in csharp

          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" <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]


          Comment

          • awk

            #6
            Re: RaiseEvent in csharp

            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


            and



            Simon

            "Nicolas" <nliebel@hotmai l.com> wrote in message
            news:uRE0l$qiDH A.560@tk2msftng p13.phx.gbl...[color=blue]
            > Thanks, but now how do I call those functions from another form as all[/color]
            this[color=blue]
            > 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" <simon.segal@mb ox.com.au> wrote in message
            > news:uNOzo$niDH A.3660@tk2msftn gp13.phx.gbl...[color=green]
            > > You havent declared an event of type one of your delegates in your[/color][/color]
            code.[color=blue][color=green]
            > >
            > > 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=darkred]
            > > > 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=darkred]
            > > > | 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[/color][/color][/color]
            e)[color=blue][color=green][color=darkred]
            > > > {
            > > > ///////////////////////////////////////// THIS IS WHERE IT DOESN'T[/color][/color][/color]
            WORK[color=blue][color=green][color=darkred]
            > > > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
            > > > //Changed(e.Chang eType);
            > > > }
            > > >
            > > > protected virtual void OnCreated(objec t sender, FileSystemEvent Args e)
            > > > {
            > > > ///////////////////////////////////////// THIS IS WHERE IT DOESN'T[/color][/color][/color]
            WORK[color=blue][color=green][color=darkred]
            > > > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
            > > > //RaiseEvent Created(e.FullP ath);
            > > > }
            > > >
            > > > protected virtual void OnRenamed(objec t sender , RenamedEventArg s a)
            > > > {
            > > > ///////////////////////////////////////// THIS IS WHERE IT DOESN'T[/color][/color][/color]
            WORK[color=blue][color=green][color=darkred]
            > > > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
            > > > //RaiseEvent ReCreated(e.Old FullPath, e.FullPath);
            > > > }
            > > >
            > > >
            > > >
            > > > Thank you
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • awk

              #7
              Re: RaiseEvent in csharp

              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


              and



              Simon

              "Nicolas" <nliebel@hotmai l.com> wrote in message
              news:uRE0l$qiDH A.560@tk2msftng p13.phx.gbl...[color=blue]
              > Thanks, but now how do I call those functions from another form as all[/color]
              this[color=blue]
              > 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" <simon.segal@mb ox.com.au> wrote in message
              > news:uNOzo$niDH A.3660@tk2msftn gp13.phx.gbl...[color=green]
              > > You havent declared an event of type one of your delegates in your[/color][/color]
              code.[color=blue][color=green]
              > >
              > > 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=darkred]
              > > > 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=darkred]
              > > > | 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[/color][/color][/color]
              e)[color=blue][color=green][color=darkred]
              > > > {
              > > > ///////////////////////////////////////// THIS IS WHERE IT DOESN'T[/color][/color][/color]
              WORK[color=blue][color=green][color=darkred]
              > > > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
              > > > //Changed(e.Chang eType);
              > > > }
              > > >
              > > > protected virtual void OnCreated(objec t sender, FileSystemEvent Args e)
              > > > {
              > > > ///////////////////////////////////////// THIS IS WHERE IT DOESN'T[/color][/color][/color]
              WORK[color=blue][color=green][color=darkred]
              > > > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
              > > > //RaiseEvent Created(e.FullP ath);
              > > > }
              > > >
              > > > protected virtual void OnRenamed(objec t sender , RenamedEventArg s a)
              > > > {
              > > > ///////////////////////////////////////// THIS IS WHERE IT DOESN'T[/color][/color][/color]
              WORK[color=blue][color=green][color=darkred]
              > > > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
              > > > //RaiseEvent ReCreated(e.Old FullPath, e.FullPath);
              > > > }
              > > >
              > > >
              > > >
              > > > Thank you
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]


              Comment

              • Nicolas

                #8
                Re: RaiseEvent in csharp

                Thank a lot , work ok now!!!
                "awk" <simon.segal@mb ox.com.au> wrote in message
                news:u9um1GviDH A.2616@TK2MSFTN GP10.phx.gbl...[color=blue]
                > 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[/color]
                filename)[color=blue]
                > {
                > 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" <nliebel@hotmai l.com> wrote in message
                > news:uRE0l$qiDH A.560@tk2msftng p13.phx.gbl...[color=green]
                > > Thanks, but now how do I call those functions from another form as all[/color]
                > this[color=green]
                > > 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" <simon.segal@mb ox.com.au> wrote in message
                > > news:uNOzo$niDH A.3660@tk2msftn gp13.phx.gbl...[color=darkred]
                > > > You havent declared an event of type one of your delegates in your[/color][/color]
                > code.[color=green][color=darkred]
                > > >
                > > > 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...
                > > > > 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,[/color][/color][/color]
                FileSystemEvent Args[color=blue]
                > e)[color=green][color=darkred]
                > > > > {
                > > > > ///////////////////////////////////////// THIS IS WHERE IT DOESN'T[/color][/color]
                > WORK[color=green][color=darkred]
                > > > > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
                > > > > //Changed(e.Chang eType);
                > > > > }
                > > > >
                > > > > protected virtual void OnCreated(objec t sender, FileSystemEvent Args[/color][/color][/color]
                e)[color=blue][color=green][color=darkred]
                > > > > {
                > > > > ///////////////////////////////////////// THIS IS WHERE IT DOESN'T[/color][/color]
                > WORK[color=green][color=darkred]
                > > > > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
                > > > > //RaiseEvent Created(e.FullP ath);
                > > > > }
                > > > >
                > > > > protected virtual void OnRenamed(objec t sender , RenamedEventArg s[/color][/color][/color]
                a)[color=blue][color=green][color=darkred]
                > > > > {
                > > > > ///////////////////////////////////////// THIS IS WHERE IT DOESN'T[/color][/color]
                > WORK[color=green][color=darkred]
                > > > > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
                > > > > //RaiseEvent ReCreated(e.Old FullPath, e.FullPath);
                > > > > }
                > > > >
                > > > >
                > > > >
                > > > > Thank you
                > > > >
                > > > >
                > > >
                > > >[/color]
                > >
                > >[/color]
                >
                >[/color]


                Comment

                • Nicolas

                  #9
                  Re: RaiseEvent in csharp

                  Thank a lot , work ok now!!!
                  "awk" <simon.segal@mb ox.com.au> wrote in message
                  news:u9um1GviDH A.2616@TK2MSFTN GP10.phx.gbl...[color=blue]
                  > 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[/color]
                  filename)[color=blue]
                  > {
                  > 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" <nliebel@hotmai l.com> wrote in message
                  > news:uRE0l$qiDH A.560@tk2msftng p13.phx.gbl...[color=green]
                  > > Thanks, but now how do I call those functions from another form as all[/color]
                  > this[color=green]
                  > > 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" <simon.segal@mb ox.com.au> wrote in message
                  > > news:uNOzo$niDH A.3660@tk2msftn gp13.phx.gbl...[color=darkred]
                  > > > You havent declared an event of type one of your delegates in your[/color][/color]
                  > code.[color=green][color=darkred]
                  > > >
                  > > > 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...
                  > > > > 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,[/color][/color][/color]
                  FileSystemEvent Args[color=blue]
                  > e)[color=green][color=darkred]
                  > > > > {
                  > > > > ///////////////////////////////////////// THIS IS WHERE IT DOESN'T[/color][/color]
                  > WORK[color=green][color=darkred]
                  > > > > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
                  > > > > //Changed(e.Chang eType);
                  > > > > }
                  > > > >
                  > > > > protected virtual void OnCreated(objec t sender, FileSystemEvent Args[/color][/color][/color]
                  e)[color=blue][color=green][color=darkred]
                  > > > > {
                  > > > > ///////////////////////////////////////// THIS IS WHERE IT DOESN'T[/color][/color]
                  > WORK[color=green][color=darkred]
                  > > > > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
                  > > > > //RaiseEvent Created(e.FullP ath);
                  > > > > }
                  > > > >
                  > > > > protected virtual void OnRenamed(objec t sender , RenamedEventArg s[/color][/color][/color]
                  a)[color=blue][color=green][color=darkred]
                  > > > > {
                  > > > > ///////////////////////////////////////// THIS IS WHERE IT DOESN'T[/color][/color]
                  > WORK[color=green][color=darkred]
                  > > > > \\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\ \\
                  > > > > //RaiseEvent ReCreated(e.Old FullPath, e.FullPath);
                  > > > > }
                  > > > >
                  > > > >
                  > > > >
                  > > > > Thank you
                  > > > >
                  > > > >
                  > > >
                  > > >[/color]
                  > >
                  > >[/color]
                  >
                  >[/color]


                  Comment

                  Working...