/// <summary> /// This sets the content type value in the registry for a given file /// extension /// </summary> /// <param name="fileExtension">the file extension (i.e. '.gif')</param> /// <param name="contentType">the content type (i.e. 'image/gif')</param> public static void SetContentType(string fileExtension, string contentType) { // try to read the registry, throw mimehelper exception if it fails try { RegistryKey extKey = Registry.ClassesRoot.CreateSubKey(fileExtension); Debug.Assert(extKey != null, "Content Type Not Set"); using (extKey) { extKey.SetValue(CONTENT_TYPE_KEY, contentType); } } catch (Exception e) { throw MimeHelperException.ForUnableToSetContentType(contentType, e); } }
/// <summary> /// Returns the quoted printable character type for a given chacacter /// </summary> /// <param name="ascii">the character to determine type</param> /// <returns>the character type</returns> private static int GetQpCharType(int ascii) { // legal ascii- if ((ascii >= 33 && ascii <= 60) || (ascii >= 62 && ascii <= 126) || (ascii == 0)) { return(LEGAL_ASCII); } // tab or space else if (ascii == 9 || ascii == 32) { return(WHITESPACE); } // lineFeed else if (ascii == 10) { return(LINEFEED); } // carriage Return else if (ascii == 13) { return(CARRIAGE_RETURN); } // high or low illegal ascii value else if ((ascii < 255 && ascii > 126) || (ascii > 0 && ascii < 33) || (ascii == 61)) { return(ILLEGAL_ASCII); } // ascii value that is unsupportable by this encoding else { // Throw illegal character exception throw MimeHelperException.ForIllegalEncodingCharacter((char)ascii, "quoted-printable", null); } }