Read/Write 'Extended' file properties (C#)

后端 未结 10 2536
我在风中等你
我在风中等你 2020-11-22 02:54

I\'m trying to find out how to read/write to the extended file properties in C# e.g. Comment, Bit Rate, Date Accessed, Category etc that you can see in Windows explorer. An

10条回答
  •  生来不讨喜
    2020-11-22 03:48

    This sample in VB.NET reads all extended properties:

    Sub Main()
            Dim arrHeaders(35)
    
            Dim shell As New Shell32.Shell
            Dim objFolder As Shell32.Folder
    
            objFolder = shell.NameSpace("C:\tmp")
    
            For i = 0 To 34
                arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
            Next
            For Each strFileName In objfolder.Items
                For i = 0 To 34
                    Console.WriteLine(i & vbTab & arrHeaders(i) & ": " & objfolder.GetDetailsOf(strFileName, i))
                Next
            Next
    
        End Sub
    

    You have to add a reference to Microsoft Shell Controls and Automation from the COM tab of the References dialog.

提交回复
热议问题