Skip to content

Instantly share code, notes, and snippets.

@DalSoft
Created July 1, 2022 11:49
Show Gist options
  • 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