Skip to content

Instantly share code, notes, and snippets.

@yetanotherchris
Created February 19, 2013 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yetanotherchris/4985418 to your computer and use it in GitHub Desktop.
Save yetanotherchris/4985418 to your computer and use it in GitHub Desktop.
Listing all mimetypes
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