Created
February 19, 2013 12:27
-
-
Save yetanotherchris/4985418 to your computer and use it in GitHub Desktop.
Listing all mimetypes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MimeType | |
{ | |
public string Extension { get; set; } | |
public string Value { get; set; } | |
public MimeType() | |
{ | |
Extension = ""; | |
Value = ""; | |
} | |
public MimeType(string extension, string value) | |
{ | |
Extension = extension; | |
Value = value; | |
} | |
public static IEnumerable<MimeType> Load() | |
{ | |
IList<MimeType> mimeTypes = new List<MimeType>(); | |
try | |
{ | |
using (Stream stream = typeof(MimeType).Assembly.GetManifestResourceStream("MimeTypes.mimetypes.xml")) | |
{ | |
XmlSerializer serializer = new XmlSerializer(typeof(List<MimeType>)); | |
mimeTypes = (IList<MimeType>)serializer.Deserialize(stream); | |
} | |
} | |
catch (Exception) | |
{ | |
// Re throw if you need | |
} | |
return mimeTypes; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment