Saturday, October 29, 2011

Getting Mimetype .NET


Private Function MimeType(Filename As String) As String
 Dim mime As String = "application/octetstream"
 Dim ext As String = System.IO.Path.GetExtension(Filename).ToLower()
 Dim rk As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext)
 If rk IsNot Nothing AndAlso rk.GetValue("Content Type") IsNot Nothing Then
  mime = rk.GetValue("Content Type").ToString()
 End If
 Return mime
End Function
In short - you just feed it with path top a file - and get back the mime type. Ex MimeType("f:\\theimage.jpg") --->>> "image/jpeg"

1 comment:

  1. Casino, Hotel & RV Park Reviews, Ratings & Photos
    Complete casino 구리 출장마사지 information 동두천 출장마사지 including address, telephone 태백 출장안마 number, photos, 익산 출장샵 videos, games, and 구리 출장샵 other amenities at Casino, Hotel & RV Park.

    ReplyDelete