mayho33
Goto Top

C-Sharp Meta-Daten (Author, Titel, Typ, usw.) aus Datei auslesen

Hallo @ All

Ich möchte die Metadaten (Details) aus einigen Schrift-Arten auslesen.

Siehe BSP:
fonts

System.IO.FileInfo usw. liefern alle nicht die Details.

Kann mir jemand einen Tipp geben wie ich das bewerkstelligen kann?

Danke für eure Hilfe!

Grüße, Mayho

Content-ID: 560423

Url: https://administrator.de/forum/c-sharp-meta-daten-author-titel-typ-usw-aus-datei-auslesen-560423.html

Ausgedruckt am: 13.04.2025 um 01:04 Uhr

143127
Lösung 143127 24.03.2020 aktualisiert um 06:39:58 Uhr
Goto Top
colinardo
Lösung colinardo 24.03.2020 aktualisiert um 13:15:42 Uhr
Goto Top
Servus @mayho ,
hier ein einfaches Beispiel in einer Console-App. (Verweis zu Shell32.dll hinzufügen und Pfad zur Font-Datei anpassen)
Eine Liste für die FMTID und die propID findest du hier
https://docs.microsoft.com/en-us/windows/win32/properties/props
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace GetExtendedProperty {
    class Program {
        [STAThread]
        static void Main(string args) {
            string filepath = @"D:\Test.otf";  
            Shell32.Shell shell = new Shell32.Shell();
            Shell32.Shell objShell = shell.Application;
            Shell32.FolderItem2 itm = (Shell32.FolderItem2)objShell.NameSpace(Path.GetDirectoryName(filepath)).ParseName(Path.GetFileName(filepath));
            Console.WriteLine("Type:\t" + itm.ExtendedProperty("{B725F130-47EF-101A-A5F1-02608C9EEBAC} 4"));  
            Console.WriteLine("Title:\t" + itm.ExtendedProperty("{F29F85E0-4FF9-1068-AB91-08002B27B3D9} 2"));  
            Console.WriteLine("File version:\t" + itm.ExtendedProperty("{0CEF7D53-FA64-11D1-A203-0000F81FEDEE} 4"));  
            Console.WriteLine("Copyright:\t" + itm.ExtendedProperty("{64440492-4C8B-11D1-8B70-080036B11A03} 11"));  
            Console.WriteLine("Company:\t" + itm.ExtendedProperty("{D5CDD502-2E9C-101B-9397-08002B2CF9AE} 15"));  
            string authors = itm.ExtendedProperty("{F29F85E0-4FF9-1068-AB91-08002B27B3D9} 4") ?? new string { };  
            Console.WriteLine("Author:\t" + String.Join(",", authors));  
            Console.WriteLine("Trademarks:\t" + itm.ExtendedProperty("{0CEF7D53-FA64-11D1-A203-0000F81FEDEE} 9"));  
            Console.WriteLine("File description:\t" + itm.ExtendedProperty("{0CEF7D53-FA64-11D1-A203-0000F81FEDEE} 3"));  

            Console.WriteLine("\n\nPress any key to exit");  
            Console.ReadKey();
        }
    }
}
Grüße Uwe
mayho33
mayho33 25.03.2020 um 01:15:21 Uhr
Goto Top
Hi vibrations, colinardo,

Danke für eure Infos. Das ist genau das was ich gebraucht habe! face-smile

Habe eure Tipps mit NuGet umgesetzt...
  • Microsoft.WindowsAPICodePack.Core
  • Microsoft.WindowsAPICodePack.Shell

...und am Ende alles via Costura.Fody in meine Exe eingebettet.

Danke für eure Hilfe!