I was looking for this for some time now. Simple, but beautiful solution:
public string GetMimeType(byte[] fileBytes)
{
try
{
ContentInfo info = new ContentInfo(fileBytes);
return info.ContentType.Value;
}
catch
{
return "application/octet-stream";
}
}
No comments:
Post a Comment