如何查找 文件的MIME类型
通过查找注册表
HKEY_CLASSES_ROOT\MIME\Database\Content Type
word的mime是application/msword
直接打开文件在网页中
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
byte[] buffer = new byte[1024];
FileStream fs = new FileStream(@"C:\test.xls",FileMode.Open,FileAccess.Read);
try
{
int i = buffer.Length;
while(i == buffer.Length)
{
i = fs.Read(buffer,0,buffer.Length);
Response.OutputStream.Write(buffer,0,i);
}
}
finally
{
fs.Close();
}
Response.Flush();