Actually I have saved some files like .pdf
,.txt
,.doc
,.xls
by converting them to <Binary data>
in my SQL SERVER DB
through FileUploadControl
.
Now, I want to Convert the <Binary data>
back to Normal and give an option for user to Download (or) View that data.
I have tried some thing like this for the .txt
files
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();
I am getting an error like :
Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.