title: Get Date Taken for NEF format images
body: <p>I have a function that gets the date taken value for pictures in JPEG format. I've run into a problem with the NEF Nikon raw format. In Windows 8 I can see the Date Taken value if I add the column to the Windows Explorer detail view. </p>
  
  <p>The error I receive when the following is executed is "This codec does not support the specified property."</p>
  
  <pre><code>public string GetDate(FileInfo f)
          {
              string date;
  
              using (FileStream fs = new FileStream(f.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
              { 
                  BitmapSource img = BitmapFrame.Create(fs);
                  BitmapMetadata md = (BitmapMetadata)img.Metadata;
                  date = md.DateTaken;
              }
  
              return date;
          }
  </code></pre>
  
  <p>I tried the suggestion in this <a href="http://www.developerfusion.com/article/84474/reading-writing-and-photo-metadata/" rel="nofollow">article</a> that is referenced in similar SO answers, using the GetQuery method for BitmapMetadata, but that returned the same error, here was the code I used:</p>
  
  <pre><code>public string GetDate(FileInfo f)
          {
              string date;
  
              using (FileStream fs = new FileStream(f.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
              { 
                  BitmapSource img = BitmapFrame.Create(fs);
                  BitmapMetadata md = (BitmapMetadata)img.Metadata;
                  object t = Mdata.GetQuery("System.Photo.DateTaken");
              }
  
              return date;
          }
  </code></pre>
  
  <p>I'm deploying this to a Windows 8 PC, so I don't mind a Windows 8 or .NET 4.5 only solution.</p>