I'm trying to get Mime type from downloaded file path.
var fileNanager = new NSFileManager();
if (!fileNanager.FileExists(path))
{
return null;
}
var uti = UniformTypeIdentifiers.UTType.GetType(Path.GetExtension(path), UniformTypeIdentifiers.UTTagClass.FilenameExtension, null);
var x = uti?.PreferredMimeType;
if (x == null)
{
return "application/octet-stream";
}
return x;
Even though there's a PDF file path uti is always null and I can only get result "application/octet-stream" instead of "application/pdf". What did I do wrong?
UniformTypeIdentifiers.UTType.GetType
requires file extension without '.' while Path.GetExtension(path)
returns a file extension with '.' included.
Removing '.' in advance does the trick.