public static string GetMIMEType(string fileName) {
if (!string.IsNullOrWhiteSpace(fileName) && Path.GetExtension(fileName).Length > 1 && /* File with an extension */
MIMETypesDictionary.ContainsKey(Path.GetExtension(fileName).Remove(0, 1))) {
return MIMETypesDictionary[Path.GetExtension(fileName).Remove(0, 1)];
}
// If no match, return generic MIME type.
return "application/octet-stream";
}
}