Search code examples
c#monopinvokefile-type

Get file type in Mono


How do i get the file type in Mono? i.e. "*.txt" => "Text Document", "*.jpg" => "JPEG Image". Similar to what SHFILEINFO.szTypeName returns with P/Invoke on Windows.


Solution

  • There is no cross-platform API for this. On Linux you can use GIO, and there are native APIs on Mac too though I don't know them offhand. On Windows you can P/Invoke from Mono.