MimeTypeMap

Class MimeTypeMap.

Syntax

public static class MimeTypeMap

Inheritance

Methods

GetExtension

public static string GetExtension(string mimeType, bool throwErrorIfNotFound = true)
Gets the extension from the provided MINE type.

Parameters

  • mimeType string: Type of the MIME.
  • throwErrorIfNotFound bool: if set to true, throws error if extension’s not found.

Returns

string The extension.

Exceptions

  • [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception):
  • [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception):

GetMimeType

public static string GetMimeType(string str)
Gets the type of the MIME from the provided string.

Parameters

  • str string: The filename or extension.

Returns

string The MIME type.

Exceptions

  • [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception):

TryGetMimeType

public static bool TryGetMimeType(string str, out string mimeType)
Tries to get the type of the MIME from the provided string.

Parameters

  • str string: The filename or extension.
  • mimeType string: The variable to store the MIME type.

Returns

bool The MIME type.

Exceptions

  • [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception):