2

Is it possible to read date taken of a video not the Created Date or Modified Date ... i tried to check the video details but i always see the Date Taken is Empty

           List<string> arrHeaders = new List<string>();

            Shell32.Shell shell = new Shell32.Shell();
            Shell32.Folder objFolder;

            objFolder = shell.NameSpace(directoryPath);

            for (int i = 0; i < short.MaxValue; i++)
            {
                string header = objFolder.GetDetailsOf(null, i);
                if (String.IsNullOrEmpty(header))
                    break;
                arrHeaders.Add(header);
            }

            foreach (Shell32.FolderItem2 item in objFolder.Items())
            {
                for (int i = 0; i < arrHeaders.Count; i++)
                {
                    Console.WriteLine("{0}\t{1}: {2}", i, arrHeaders[i], objFolder.GetDetailsOf(item, i));
                }
            }
Lemo
  • 519
  • 1
  • 7
  • 22

1 Answers1

0
using System;
using System.IO;
using System.Windows.Media.Imaging;

class Program
{
    static void Main(string[] args)
    {
        string videoFilePath = "C:\\path\\to\\video.mp4";

        BitmapMetadata metadata = null;

        using (FileStream fs = new FileStream(videoFilePath, FileMode.Open, FileAccess.Read))
        {
            using (var decoder = BitmapDecoder.Create(fs, BitmapCreateOptions.DelayCreation, BitmapCacheOption.None))
            {
                metadata = (BitmapMetadata)decoder.Metadata;
            }
        }

        string dateTaken = metadata.DateTaken;
        Console.WriteLine("Date Taken: " + dateTaken);
    }
}
Beshoy Hindy
  • 164
  • 2
  • 9