title: Directory.GetDirectories return empty string inside an async Task operation
body: <p>I have a UWP application which perform to capture and process images from a camera.  This project leverage Microsoft Cognitive Services Face Recognition API and I'm exploring the application's existing functionality for awhile now.  My goal is that when the image of a person is identified by the camera (through Face Recognition API service), I want to show the associated image of that person.</p>
  
  <p>With that, the images are captured and stored in a local directory of my machine.  I want to retrieve the image file and render it on the screen once the person is identified.</p>
  
  <p>The code below shows the <code>async</code> Task method <code>ProcessCameraCapture</code></p>
  
  <pre><code>private async Task ProcessCameraCapture(ImageAnalyzer e)
      {
          if (e == null)
          {
              this.UpdateUIForNoFacesDetected();
              this.isProcessingPhoto = false;
              return;
          }
  
          DateTime start = DateTime.Now;
  
          await e.DetectFacesAsync();
  
          if (e.DetectedFaces.Any())
          {
              string names;
              await e.IdentifyFacesAsync();
  
              this.greetingTextBlock.Text = this.GetGreettingFromFaces(e, out names);
  
              if (e.IdentifiedPersons.Any())
              {
                  this.greetingTextBlock.Foreground = new SolidColorBrush(Windows.UI.Colors.GreenYellow);
                  this.greetingSymbol.Foreground = new SolidColorBrush(Windows.UI.Colors.GreenYellow);
                  this.greetingSymbol.Symbol = Symbol.Comment;
  
                  GetSavedFilePhoto(names);
              }
              else
              {
                  this.greetingTextBlock.Foreground = new SolidColorBrush(Windows.UI.Colors.Yellow);
                  this.greetingSymbol.Foreground = new SolidColorBrush(Windows.UI.Colors.Yellow);
                  this.greetingSymbol.Symbol = Symbol.View;
              }
          }
          else
          {
              this.UpdateUIForNoFacesDetected();
          }
  
          TimeSpan latency = DateTime.Now - start;
          this.faceLantencyDebugText.Text = string.Format("Face API latency: {0}ms", (int)latency.TotalMilliseconds);
  
          this.isProcessingPhoto = false;
      }
  </code></pre>
  
  <p>In <code>GetSavedFilePhoto</code>, I passed the string names argument once the person is identified.</p>
  
  <p>Code below for the <code>GetSavedFilePhoto</code> method</p>
  
  <pre><code>private void GetSavedFilePhoto(string personName)
      {
          if (string.IsNullOrWhiteSpace(personName)) return;
  
          var directoryPath = @"D:\PersonImages";
  
          var directories = Directory.GetDirectories(directoryPath);
          var filePaths = Directory.GetFiles(directoryPath, "*.jpg", SearchOption.AllDirectories);
      }
  </code></pre>
  
  <p>However, in <code>GetSavedFilePhoto</code> method the variable <code>directories</code> returned an empty string of array when using <code>directoryPath</code> string variable.  Directory "D:\PersonImages" is a valid and existing folder in my machine and, it contains subfolders with images inside.  I also tried <code>Directory.GetFiles</code> to retrieve the jpg images but still returned an empty string.</p>
  
  <p>I think it should work because I have used <code>Directory</code> class several times but not inside an <code>async</code>Task method. Does using <code>async</code> caused the files not returned when using I/O operation?</p>
  
  <p>Sorry for this stupid question, but I really don't understand.</p>
  
  <p>Any help is greatly appreciated.</p>