Skip to content

Instantly share code, notes, and snippets.

@DalSoft
Created July 1, 2022 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DalSoft/ef86083643ea7b0bf253034855041dad to your computer and use it in GitHub Desktop.
Save DalSoft/ef86083643ea7b0bf253034855041dad to your computer and use it in GitHub Desktop.
GetMimeTypeForFileExtension
private static string GetMimeTypeForFileExtension(string filePath)
{
const string defaultContentType = "application/octet-stream";
if (!new FileExtensionContentTypeProvider().TryGetContentType(filePath, out string contentType))
{
contentType = defaultContentType;
}
return contentType;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment