gitlabEdit

wand-magic-sparklesFile Magic Tools

Magic wand that points at your files.

We have wrapped the file magic tools under a class called MagicHandler that is found under the Magico.Files namespace. It wraps the libmagic library with the magic.mgc magic file that is embedded to the library to allow systems that don't have file and libmagic installed to work, thus achieving portability.


Some of the tools

You can use some of the tools by expanding one of the below expandables:

chevron-rightObtaining the libmagic versionhashtag

You can check the libmagic version identifier using the MagicVersionId property.

chevron-rightObtaining the magic file pathshashtag

You can get the magic file paths using the GetMagicPaths() function, though this is usually not necessary.

chevron-rightObtaining detailed file summaryhashtag

To get a detailed file summary, you can use the GetMagicInfo() function, pointing to the path of the file, to get a summary that is similar to the file command that you may have installed in your Linux distribution.

chevron-rightObtaining MIME information about a filehashtag

You can get the MIME information about your file using the file data and magic number as the indicator instead of simply the file extension. The following functions provide this info:

  • GetMagicMimeInfo()

  • GetMagicMimeType()

  • GetMagicCustomType()

Last updated