C# - Add, edit and delete tags of file

前端 未结 1 1806
逝去的感伤
逝去的感伤 2020-12-21 01:54

I would like to add and retrieve tags of files in File System.

As you can tag Stackoverflow question to the relevant topics, you can tag a file in Windows file-s

1条回答
  •  离开以前
    2020-12-21 02:22

    As you can tag Stackoverflow question to the relevant topics, you can tag a file in Windows file-system

    This assumption is wrong. You can't add tags to all file types. See here:

    Note

    You cannot add or modify the file properties of some types of files. For example, you can add or modify the properties of Microsoft Office documents and Searches, but you can't add or modify the properties of TXT or RTF files.

    Besides the types mentioned there are others which can contain custom tags:

    • mp3 files can contain ID3 tag of various versions
    • flac and ogg files can contain ogg-vorbis tags
    • jpeg files can contain exif data
    • pdf files can contain various info fields

    Editing/adding/removing those tags should be done with dedicated libraries.

    This post has a nice explanation:

    In Windows Explorer you can see quite a lot of document properties for many file types. The nice, unified interface suggests that there is some unified property store. That's not really the case. The Explorer Shell has an extensible interface for Property Sheet Handlers that extract this information from various file types. There is a handler for JFIF (JPEG) files, and there are handlers for OLE files (old Office formats), and the new Office formats too.

    And this post shows how the OP successfully adds tags via ShellFile.

    Also recommended reading: Getting and Setting File Tag Meta Information in C#

    0 讨论(0)
提交回复
热议问题