![]() |
VOOZH | about |
dotnet add package Mime --version 3.8.0
NuGet\Install-Package Mime -Version 3.8.0
<PackageReference Include="Mime" Version="3.8.0" />
<PackageVersion Include="Mime" Version="3.8.0" />Directory.Packages.props
<PackageReference Include="Mime" />Project file
paket add Mime --version 3.8.0
#r "nuget: Mime, 3.8.0"
#:package Mime@3.8.0
#addin nuget:?package=Mime&version=3.8.0Install as a Cake Addin
#tool nuget:?package=Mime&version=3.8.0Install as a Cake Tool
.NET wrapper for libmagic
via NuGet:
PM> Install-Package Mime
Supported runtimes:
using HeyRed.Mime;
// (Optionally) You can set path to magic database file manually.
MimeGuesser.MagicFilePath = "/path/to/magic.mgc";
// Guess mime type of file(overloaded method takes byte array or stream as arg.)
MimeGuesser.GuessMimeType("path/to/file"); //=> image/jpeg
// Get extension of file(overloaded method takes byte array or stream as arg.)
MimeGuesser.GuessExtension("path/to/file"); //=> jpeg
// Get mime type and extension of file(overloaded method takes byte array or stream as arg.)
MimeGuesser.GuessFileType("path/to/file"); //=> FileType
Want more than just the mime type? Use the Magic class:
string calc = @"C:\Windows\System32\calc.exe";
using var magic = new Magic(MagicOpenFlags.MAGIC_NONE);
magic.Read(calc); //=> PE32+ executable (GUI) x86-64, for MS Windows
// Check encoding:
string textFile = @"F:\Temp\file.txt";
using var magic = new Magic(MagicOpenFlags.MAGIC_MIME_ENCODING);
magic.Read(textFile); //=> Output: utf-8
Also, we can combine flags with "|" operator. See all for more info.
| Exception | Solution |
|---|---|
| DllNotFoundException | Make sure that your bin folder contains runtimes directory. If you publishing platform dependent app, then bin should be contains libmagic-1(.dll, .so or .dylib) and magic.mgc files. |
| BadImageFormatException | Make sure when you target the AnyCPU platform the Prefer 32-bit option is unchecked. Or try to target x64/arm64 instead. |
| MagicException: Could not find any valid magic files! | Make sure your magic.mgc file contains in one of /runtimes/ subdirs or along with libmagic-1.[dll|lib|dylib]. Or set path to custom database as described in basic usage |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 is compatible. net48 net48 is compatible. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Mime:
| Package | Downloads |
|---|---|
|
NsfwSpy
NsfwSpy is an image and video classifier used to identify explicit/pornographic content using machine learning. |
|
|
SparkPostCore
.Net Core port of SparkPost class libary for using REST API. https://github.com/darrencauthon/csharp-sparkpost |
|
|
BXJG.Utils
Package Description |
|
|
DanSaul.SharedCode
Package Description |
|
|
Downlink
The main Downlink package including the controllers and infrastructure code |
Showing the top 1 popular GitHub repositories that depend on Mime:
| Repository | Stars |
|---|---|
|
NsfwSpy/NsfwSpy.NET
A .NET image and video classifier used to identify explicit/pornographic content written in C#.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.8.0 | 341,052 | 8/7/2025 |
| 3.7.0 | 699,787 | 12/14/2024 |
| 3.6.0 | 1,079,843 | 12/5/2023 |
| 3.5.2 | 324,906 | 2/27/2023 |
| 3.5.1 | 2,188 | 2/25/2023 |
| 3.4.1 | 123,273 | 12/12/2022 |
| 3.4.0 | 263,724 | 5/22/2022 |
| 3.3.0 | 179,724 | 12/2/2021 |
| 3.2.3 | 306,261 | 7/5/2021 |
| 3.2.2 | 251,905 | 9/11/2020 |
| 3.2.1 | 2,055 | 9/11/2020 |
| 3.1.0 | 208,736 | 1/9/2020 |
| 3.0.2 | 1,096,258 | 10/23/2018 |
| 3.0.1 | 66,678 | 5/13/2018 |
| 3.0.0 | 67,799 | 12/28/2017 |
| 2.3.5 | 96,926 | 8/19/2017 |
| 2.3.4 | 3,686 | 8/17/2017 |