title: Setting MimeType in C#
body: <p>Is there a better way of setting mimetypes in C# than the one I am trying to do
  thanks in advance.</p>
  
  <pre><code>static String MimeType(string filePath)
  {
    String ret = null;
    FileInfo file = new FileInfo(filePath);
  
    if (file.Extension.ToUpper() == ".PDF")
    {
      ret = "application/pdf";
    }
    else if (file.Extension.ToUpper() == ".JPG" || file.Extension.ToUpper() == ".JPEG")
    {
      ret = "image/jpeg";
    }
    else if (file.Extension.ToUpper() == ".PNG")
    {
      ret = "image/png";
    }
    else if (file.Extension.ToUpper() == ".GIF")
    {
      ret = "image/gif";
    }
    else if (file.Extension.ToUpper() == ".TIFF" || file.Extension.ToUpper() == ".TIF")
    {
      ret = "image/tiff";
    }
    else
    {
      ret = "image/" + file.Extension.Replace(".", "");
    }
  
    return ret;
  }
  </code></pre>