title: How to fix a DirectoryNotFoundException?
body: <p>I'm trying to overlay a local image on to a video feed from a Kinect sensor but when I overlay the image I get a <code>DirectoryNotFoundException</code> even though the image directory seems to be correct.Does anyone have an explanation as to why I could be getting this error or how to fix it?</p>
  
  <p>Throws the DirectoryNotFoundException at this line of code:</p>
  
  <pre><code>drawingContext.DrawImage(overlayImage, new Rect(12, 12, overlayImage.Width, overlayImage.Height));
  </code></pre>
  
  <p>The complete method below is taking a video feed from a Kinect sensor and overlaying an image to the video feed. The program crashes when I use the code to draw the overlay but working fine without it.</p>
  
  <pre><code>void myKinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
  {
      using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
      {
          if (colorFrame == null) return;
          byte[] colorData = new byte[colorFrame.PixelDataLength];
          colorFrame.CopyPixelDataTo(colorData);
          KinectVideo.Source = BitmapSource.Create(colorFrame.Width, colorFrame.Height, 96, 96,
                  PixelFormats.Bgr32, null, colorData, colorFrame.Width * colorFrame.BytesPerPixel);
  
          //drawing image overlay to video feed
          var drawingVisual = new DrawingVisual();
          var drawingContext = drawingVisual.RenderOpen();
          drawingContext.DrawImage(BitmapSource.Create(colorFrame.Width, colorFrame.Height, 96, 96, PixelFormats.Bgr32, null, colorData, colorFrame.Width * colorFrame.BytesPerPixel), 
                  new Rect(new Size(colorFrame.Width, colorFrame.Height)));
          var overlayImage = new BitmapImage(new Uri("Images/boxbag.png", UriKind.Relative));
          //Error thrown here --&gt;
          drawingContext.DrawImage(overlayImage, new Rect(12, 12, overlayImage.Width, overlayImage.Height));
          drawingContext.Close();
          var mergedImage = new RenderTargetBitmap(colorFrame.Width, colorFrame.Height, 96, 96, PixelFormats.Pbgra32);
          mergedImage.Render(drawingVisual);
          KinectVideo.Source = mergedImage;
      }
  }
  </code></pre>
  
  <p>This is the complete error as shown in Visual Studio, what I understand from the error is that theimage is not present in the folder, but doesn't make sense as the image is stored in a folder named <code>Images</code> in the project solution.</p>
  
  <pre><code>An unhandled exception of type 'System.IO.DirectoryNotFoundException' occurred in PresentationCore.dll
  
  Additional information: Could not find a part of the path 'C:\Users\Brian Smith\documents\visual studio 2013\Projects\KinectKickboxingBVversion1\KinectKickboxingBVversion1\bin\x86\Debug\Images\boxbag.png'
  </code></pre>
  
  <p>.</p>
  
  <p>This is the full path to the image according to VS:</p>
  
  <pre><code>C:\Users\Brian Smith\documents\visual studio 2013\Projects\KinectKickboxingBVversion1\KinectKickboxingBVversion1\Images\boxbag.png
  </code></pre>