public GetMimeTypeByContent ( Stream data ) : |
||
data | Stream | are the first bytes of data of the content to analyze. /// Depending on the length of provided data, all known MimeTypes are /// checked. If the length of provided data is greater or egals to /// the value returned by {@link #getMinLength()}, then all known /// MimeTypes are checked, otherwise only the MimeTypes that could be /// analyzed with the length of provided data are analyzed. /// /// |
return |
public static string GetMimeTypeString(string filePath) { var mimeTypes = new MimeTypes(); MimeType mimeType; using (var fileStream = new FileStream(filePath, FileMode.Open)) { mimeType = mimeTypes.GetMimeTypeByContent(fileStream); } if (mimeType == null) { mimeType = mimeTypes.GetMimeType(filePath); } if (mimeType == null) { return(null); } return(mimeType.Name); }
public static string GetMimeTypeString(string filePath) { var mimeTypes = new MimeTypes(); MimeType mimeType; using (var fileStream = new FileStream(filePath, FileMode.Open)) { mimeType = mimeTypes.GetMimeTypeByContent(fileStream); } if (mimeType == null) { mimeType = mimeTypes.GetMimeType(filePath); } if (mimeType == null) { return null; } return mimeType.Name; }