Entwickler-Ecke

Multimedia / Grafik - EXIF - Information - DateTaken (WPF - Projekt)


hth - Fr 30.01.15 18:08
Titel: EXIF - Information - DateTaken (WPF - Projekt)

C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
FileInfo fi1 = new FileInfo("D:/Test.JPG");

FileStream fs = new FileStream(fi1.FullName, FileMode.Open, FileAccess.Read, FileShare.Read);

BitmapFrame bitmapFrame = BitmapFrame.Create(fs, BitmapCreateOptions.None, BitmapCacheOption.None);           

BitmapMetadata bitmapMetadata = bitmapFrame.Metadata as BitmapMetadata;      

var _date = (bitmapMetadata.GetQuery("System.Photo.DateTaken"));

-----------------------------------------------------------

"_date" wird mir als "System.Runtime.InteropServices.ComTypes.FILETIME" angezeigt.

Ich benötige die eigentliche Erstellungszeit als String oder (und) als ulong.


hth

Moderiert von user profile iconTh69: C#-Tags hinzugefügt


Th69 - Sa 31.01.15 11:13

Hallo und :welcome:

FILETIME [https://msdn.microsoft.com/de-de/library/system.runtime.interopservices.comtypes.filetime%28v=vs.110%29.aspx] ist eine Struktur, die zwei Felder für Datum und Zeit (High und Low) bereitstellt. Diese müssen dann noch zu einem long zusammengefügt und dann konvertiert werden. Dafür stellt DateTime eine statische Methode bereit:

C#-Quelltext
1:
2:
long ft = (((long)fileTime.dwHighDateTime) << 32) | ((uint)fileTime.dwLowDateTime);
DateTime dateTime = DateTime.FromFileTimeUtc(ft);

Ein ausführlicheres Beispiel gibt es bei PInvoke.net unter FILETIME [http://pinvoke.net/default.aspx/Structures/FILETIME.html].