title: Image's given path format not supported
body: <p>I have a program that saves images, but when I debug it I get this error:</p>
  
  <blockquote>
    <p>The given path's format is not supported.</p>
  </blockquote>
  
  <p>I want to know why it is not supported, and how to fix this issue. Thanks in advance
  <br/></p>
  
  <h2>My Code</h2>
  
  <pre><code>BitmapSource image = BitmapSource.Create(colorFrame.Width, colorFrame.Height, 
                       96, 96, PixelFormats.Bgr32, null, pixels, stride);
  
  ImageFormat format = ImageFormat.Jpeg;
  
  string file_name = "C:\\Kinected\\Images\\Kinect" + bb1 + ".jpg";
  
  image.Save(file_name, format);
  </code></pre>
  
  <h3>Edit</h3>
  
  <p>I have added the code, and it compiles correctly, but the file never saves. Here's the code:</p>
  
  <pre><code>string mypath = System.IO.Path.Combine(@"C:\", "Kinected", "Images");
  if (!Directory.Exists(mypath))
    {
         Directory.CreateDirectory(mypath);
         file_name = System.IO.Path.Combine(mypath, "Kinect 1" + bb1 + ".jpeg");
    }
  
  if (file_name == null)
   {
         return;
   }
  
  if (!Directory.Exists(file_name))
   {
          Directory.CreateDirectory(file_name);
   }
  </code></pre>
  
  <h3>Edit</h3>
  
  <p>I have added all of the below code, but I still get the <code>The given path's format is not supported.</code> error. Thanks again.</p>
  
  <pre><code>BitmapSource image = BitmapSource.Create(
                  colorFrame.Width, colorFrame.Height, 96, 96, PixelFormats.Bgr32, null, pixels, stride);
  
              totalFrames = colorFrame.FrameNumber;
              ImageFormat format = ImageFormat.Jpeg;                
  
              if (PersonDetected == true)
              {
                  if (!Directory.Exists(mypath))
                  {
                      Directory.CreateDirectory(mypath);
                      file_name = "C:\\Kinected\\Images\\Kinect 1 " + bb1 + ".jpeg";
                  }
                  if (file_name == null || mypath == null || image == null)
                  {
                      if (mypath == null)
                      {
                          mypath = System.IO.Path.Combine("D:/", "Kinected", "Images");
  
                          if (!Directory.Exists(mypath))
                          {
                              Directory.CreateDirectory(mypath);
                          }
                      }
  
                      if (file_name == null)
                      {
                          file_name = "D:\\Kinected\\Images\\Kinect " + bb1 + ".jpeg";
                      }
  
                      if (image == null)
                      {
                          image = BitmapSource.Create(
                                       colorFrame.Width, colorFrame.Height, 96, 96, PixelFormats.Bgr32, null, pixels, stride);
                      }
                  }
  
                  if (totalFrames % 10 == 0)
                  {
                      if (file_name != null &amp;&amp; image != null &amp;&amp; format != null)
                      {
                          image.Save(file_name, format);//where I get the error
                      }
                  }
              }
  </code></pre>