Click here to Skip to main content
12,244,489 members (42,012 online)
Click here to Skip to main content
Articles » Languages » C# » General » Downloads

Stats

93.4K views
3.2K downloads
38 bookmarked
Posted

A C# Implementation of Mime De/encode

, 21 Aug 2005 CPOL
A C# implementation of Mime de/encode
using System;

namespace MIME
{
	/// <summary>
	/// 
	/// </summary>
	public class MimeType
	{
		public MimeType()
		{
			// 
			// TODO: Add constructor logic here
			//
		}

		
		public struct MediaTypeCvt
		{
			public MediaType nMediaType;
			public string pszSubType;
			public string pszFileExt;
			public MediaTypeCvt(MediaType nMediaType, string pszSubType, string pszFileExt)
			{
				this.nMediaType = nMediaType;
				this.pszSubType = pszSubType;
				this.pszFileExt = pszFileExt;
			}
		}

		public enum MediaType
		{
			MEDIA_TEXT=0, MEDIA_IMAGE, MEDIA_AUDIO, MEDIA_VEDIO, MEDIA_APPLICATION,
			MEDIA_MULTIPART, MEDIA_MESSAGE,
			MEDIA_UNKNOWN
		}

		public static readonly string[] TypeTable = {"text", "image", "audio", "vedio", "application", "multipart", "message", null};

		public static readonly MediaTypeCvt[]  TypeCvtTable = 
			new MediaTypeCvt[] {
								   // media-type, sub-type, file extension
								   new MediaTypeCvt( MediaType.MEDIA_APPLICATION, "xml", "xml" ),
								   new MediaTypeCvt( MediaType.MEDIA_APPLICATION, "msword", "doc" ),
								   new MediaTypeCvt( MediaType.MEDIA_APPLICATION, "rtf", "rtf" ),
								   new MediaTypeCvt( MediaType.MEDIA_APPLICATION, "vnd.ms-excel", "xls" ),
								   new MediaTypeCvt( MediaType.MEDIA_APPLICATION, "vnd.ms-powerpoint", "ppt" ),
								   new MediaTypeCvt( MediaType.MEDIA_APPLICATION, "pdf", "pdf" ),
								   new MediaTypeCvt( MediaType.MEDIA_APPLICATION, "zip", "zip" ),

								   new MediaTypeCvt( MediaType.MEDIA_IMAGE, "jpeg", "jpeg" ),
								   new MediaTypeCvt( MediaType.MEDIA_IMAGE, "jpeg", "jpg" ),
								   new MediaTypeCvt( MediaType.MEDIA_IMAGE, "gif", "gif" ),
								   new MediaTypeCvt( MediaType.MEDIA_IMAGE, "tiff", "tif" ),
								   new MediaTypeCvt( MediaType.MEDIA_IMAGE, "tiff", "tiff" ),

								   new MediaTypeCvt( MediaType.MEDIA_AUDIO, "basic", "wav" ),
								   new MediaTypeCvt( MediaType.MEDIA_AUDIO, "basic", "mp3" ),

								   new MediaTypeCvt( MediaType.MEDIA_VEDIO, "mpeg", "mpg" ),
								   new MediaTypeCvt( MediaType.MEDIA_VEDIO, "mpeg", "mpeg" ),

								   new MediaTypeCvt( MediaType.MEDIA_UNKNOWN, "", "" )		// add new subtypes before this line
							   };
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

tauyoung
Web Developer
China China
I think I have to start coding my life now...Smile | :)

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160426.1 | Last Updated 22 Aug 2005
Article Copyright 2005 by tauyoung
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid