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


Working...