Class MimeUtil
Definition
- Assembly:
- Tizen.Content.MimeType.dll
The MimeUtil API provides functions to map the MIME types to file extensions and vice versa.
C#Copypublic static class MimeUtil
- Inheritance
-
objectMimeUtil
Remarks
Conversions are provided from the file extensions to MIME types and from the MIME types to file extensions.
Methods
GetFileExtension(string)
Retrieves the file extensions associated with the specified MIME type.
Declaration
C#Copypublic static IEnumerable<string> GetFileExtension(string mime)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mime | The MIME type for which you want to retrieve the associated file extensions. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<T><string> | An enumerable collection of file extension strings for the specified MIME type. |
Remarks
By calling this function with a specific MIME type argument, you can obtain a list of file extensions related to that MIME type. These file extensions are returned without the leading period ('.') character.
Examples
In the following code snippet, we demonstrate how to utilize the GetFileExtension method by retrieving the file extensions associated with the video/mpeg MIME type:
Copyvar fileExtensions = MimeUtil.GetFileExtension("video/mpeg"); foreach (var extension in fileExtensions) { Console.WriteLine(extension); }
GetMimeType(string)
Retrieves the MIME type for the specified file extension. If no specific file format is associated with the given file extension, the default MIME type 'application/octet-stream' is returned.
Declaration
C#Copypublic static string GetMimeType(string fileExtension)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileExtension | The file extension for which the MIME type needs to be retrieved. |
Returns
| Type | Description |
|---|---|
| string | The MIME type for the specified file extension. |
Remarks
Conversions are provided from the file extensions to MIME types and from the MIME types to file extensions.
Examples
Copystring mimeType = MimeUtil.GetMimeType("png");