Question: I am trying to develop a proof of concept WCF web service which uses the FileSystemWatcher class to listen to a directory and simply outputs the type of change and the full path of files which are changed.

I have a sample console application which works as expected but when I port this into a WCF library the event handler for file changes never fires.

Code:

```
    public void MonitorFolder()
    {
        System.IO.FileSystemWatcher watcher = new System.IO.FileSystemWatcher();
        watcher.Path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "folder-to-watch");
        watcher.IncludeSubdirectories = false;
        watcher.Changed += watcher_Changed;
        watcher.Filter = "*.*";
        watcher.NotifyFilter = NotifyFilters.LastAccess |
                     NotifyFilters.LastWrite |
                     NotifyFilters.FileName |
                     NotifyFilters.DirectoryName;
        watcher.EnableRaisingEvents = true;
    }

    void watcher_Changed(object sender, System.IO.FileSystemEventArgs e)
    {
        Console.WriteLine(string.Format("Change: {0}, File: {1}", e.ChangeType, e.FullPath));
    }

```

And inside the client class which calls the service:

```
    static void Main(string[] args)
    {
        FileListenerClient c = new FileListenerClient();
        c.MonitorFolder();
        c.Close();
    }

```

Any ideas why this does not pick up file changes?

Answer: 
`Environment.SpecialFolder.Desktop` means desktop of current user. 

If your service stars under `LocalSystem` account (or similar), then it monitors its own desktop, not the desktop of current interactive user, where you're changing files or folders. 

Of course, desktop of service account remains unchanged, thus, event doesn't fire.
Maybe you misunderstood the purpose of a WCF service compared to a normal Windows Service. A WCF service is by default only activated on call. It is not something that is running all the time in the background like a normal Windows Service. 

For your exact example, you will probably need a kind of waiting before you close and you need your watcher to be just a local variable in your function, but a class variable for it to work.