熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

asp.net下載文件

2022-06-13   來源: .NET編程 

  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
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.