//实现思路,首先从数据库中把二进制 写入到服务器上 生成临时文件,然后再从服务器上 进行下载 //具体代码如下: string filename="test.jpg";//这个就是要存放到服务器的文件名 Response.ContentType = "application/octet-stream"; byte[] binaryFile = updowm.LoadDownBinaryFile(Convert.ToInt32(ViewState["ID"]), fileType, out filename); Response.Buffer = true; Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment;filename=" + filename); FileStream fs = new FileStream(Server.MapPath("~/LoadDown") + @"/" + filename, FileMode.OpenOrCreate); BinaryWriter bw = new BinaryWriter(fs); bw.Write(binaryFile, 0, binaryFile.Length); Response.OutputStream.Write(binaryFile, 0, binaryFile.Length); bw.Close(); fs.Close(); //以上是从数据库读取 并且写入到服务器的过程,记住流操作一定要关闭,下面则是从服务器进行下载的过程 Response.WriteFile(Server.MapPath("~/LoadDown") + @"/" + filename); Response.Flush(); Response.End();