SystemIOFileInfo file = new SystemIOFileInfo(pstrFilePath);
if (fileExists)
{
ResponseClear();
ResponseCharset = GB;
ResponseContentEncoding = SystemTextEncodingUTF;
ResponseAddHeader(ContentDisposition attachment;filename= + ServerUrlEncode(fileName));
ResponseAddHeader(ContenLength fileLengthToString());
ResponseContentType = application/msexcel;
ResponseWriteFile(fileFullName);
ResponseEnd();
}
下面是更詳細的ContentType
ez => application/andrewinset
hqx => application/macbinhex
cpt => application/maccompactpro
doc => application/msword
bin => application/octetstream
dms => application/octetstream
lha => application/octetstream
lzh => application/octetstream
exe => application/octetstream
class => application/octetstream
so => application/octetstream
dll => application/octetstream
oda => application/oda
pdf => application/pdf
ai => application/postscript
eps => application/postscript
ps => application/postscript
smi => application/smil
smil => application/smil
mif => application/vndmif
xls => application/vndmsexcel
ppt => application/vndmspowerpoint
wbxml => application/vndwapwbxml
wmlc => application/vndwapwmlc
wmlsc => application/vndwapwmlscriptc
bcpio => application/xbcpio
vcd => application/xcdlink
pgn => application/xchesspgn
cpio => application/xcpio
csh => application/xcsh
dcr => application/xdirector
dir => application/xdirector
From:http://tw.wingwit.com/Article/program/net/201311/12594.html