sharp-application-server/mime/MimeHelper.cs

27 lines
647 B
C#

using System;
using System.Collections.Generic;
namespace appsrv.mime
{
public static class MimeHelper
{
static Dictionary<string, string> extToMIME = new Dictionary<string, string>()
{
{"html","text/html"},
{"htm","text/html"},
{"xml","text/xml"},
{"txt","text/plain"}
};
public static String GuessMIMEFromFilename(String filename){
foreach (String ext in extToMIME.Keys){
if (filename.EndsWith(ext))
return extToMIME[ext];
}
return "application/octet-stream";
}
}
}