string fileName = 文件名string filePath = ServerMapPath(……/DOC_FILE/) + fileName // ……/DOC_FILE/ 下载文件的文件夹路径if (FileExists(filePath))
{ //以字符流的形式下载文件FileStream fs = new FileStream(filePath FileModeOpen)byte[] bytes = new byte[(int)fsLength]fsRead(bytes bytesLength)fsClose()ResponseContentType = application/octetstream//通知浏览器下载文件而不是打开ResponseAddHeader(ContentDisposition attachment filename= + HttpUtilityUrlEncode(fileName SystemTextEncodingUTF))ResponseBinaryWrite(bytes)ResponseFlush()ResponseEnd()} else { JScriptAlert(this 文件不存在!)