实际上我已经保存了一些文件,例如 . pdf
,. txt
,. doc
,. xls
通过将它们转换为<Binary data>
我的SQL SERVER DB
through FileUploadControl
。现在,我想将<Binary data>
背面转换为正常并为用户提供下载(或)查看该数据的选项。
我已经为 . txt
文件
var filedata = (from xx in VDC.SURVEY_QUESTION_REPLIES
where xx.ID == FileID
select xx).FirstOrDefault();
string fileextension = filedata.FILE_EXTENSION.ToString();
string fileName = filedata.ANSWER_TEXT.ToString() + fileextension;
Byte[] bytes = (Byte[])filedata.FILE_DATA;
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
我收到如下错误:
无法计算表达式,因为代码已优化或本机框架位于调用堆栈顶部。