Private voidDownLoad (stringFileName,stringpath) {FileInfo fi=NewFileInfo (path); if(FI. Exists) {response.clear (); Response.clearcontent (); Response.ClearHeaders (); Response.Buffer=true; Response.AddHeader ("content-disposition","attachment;filename="+fileName); Response.AddHeader ("Content-length", FI. Length.tostring ()); Response.AddHeader ("content-transfer-encoding","binary"); Response.ContentType="Application/octet-stream"; Response.ContentEncoding= System.Text.Encoding.GetEncoding ("gb2312"); Response.WriteFile (path); Response.Flush (); Response.End (); } } Private voidDownLoad2 (stringFileName,stringpath) {FileInfo fi=NewFileInfo (path); if(FI. Exists) {response.clear (); Response.Buffer=true; Response.AddHeader ("content-disposition","attachment;filename="+fileName); Response.ContentType="Application/unknow"; Response.TransmitFile (path); Response.End (); } }
ASP. Response Download File