Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.