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-Key: 560423

Url: https://administrator.de/contentid/560423

Printed on: April 26, 2024 at 06:04 o'clock

Mitglied: 143127
Solution 143127 Mar 24, 2020 updated at 05:39:58 (UTC)
Goto Top
Member: colinardo
Solution colinardo Mar 24, 2020 updated at 12:15:42 (UTC)
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
Member: mayho33
mayho33 Mar 25, 2020 at 00:15:21 (UTC)
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!