0
我有二進制數組形式的文件,我需要瀏覽器打開下載對話框並保存文件。從網頁上的二進制數組下載文件
我試圖
Response.BinaryWrite(fileData);
,但它只是增加了二進制字符的頁面,並沒有打開一個下載對話!
我有二進制數組形式的文件,我需要瀏覽器打開下載對話框並保存文件。從網頁上的二進制數組下載文件
我試圖
Response.BinaryWrite(fileData);
,但它只是增加了二進制字符的頁面,並沒有打開一個下載對話!
試試這個:
Response.Clear();
Response.AppendHeader("content-disposition", "attachment; filename=fileToDownload");
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(fileData);
Response.Flush();
Response.End();
您也需要設置內容類型:
Response.ContentType = "application/octet-stream";