title: Can't Create Reliable "Watch Folder" in UWP App
body: <pre><code>public class WatchFolder
  {
      public bool ChangesMade { get; set; }
  
      public WatchFolder()
      {
          ChangesMade = false;
      }
  
      public async void InitializeFolderWatch()
      {
          var folder = KnownFolders.PicturesLibrary.GetFolderAsync("TestWatchFolder");
          var options = new QueryOptions();
          options.FolderDepth = FolderDepth.Deep;
          var fileQuery = folder.CreateFileQueryWithOptions(options);
          fileQuery.ContentsChanged += OnContentsChangedFolder;
          var files = await fileQuery.GetFilesAsync();           
      }
  
      private void OnContentsChangedFolder(IStorageQueryResultBase sender, object args)
      {
          ChangesMade = true;
      }
  }
  </code></pre>
  
  <p>I'm trying to get a watch folder working for a Windows 10 Store app.  When debugging the above code works fine at first.  The event fires and will continue to fire every time I add a file to the watch folder (or remove one) using Windows File Explorer. But if I interact with the <a href="/questions/tagged/uwp" class="post-tag" title="show questions tagged &#39;uwp&#39;" rel="tag">uwp</a> app's UI for a few seconds then then try again it won't fire thereafter.</p>
  
  <p>I have tried instantiating it in both the code-behind and the view model, same result.  I've also tried converting it to a static method, same result.</p>