Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tried the below c# code to write my file table content(file stream -varbinary column) to one excel file. It is downloading the contents to excel file. But i need to save the excel file to the predefined path only. No need to download or open the file.

C#
using (SqlDataReader rdr = DAL.executeQuery(sql, _params))
           {
               if (rdr.Read())
               {
                   Byte[] buffer = (Byte[])rdr["file_stream"];

                   Response.ClearContent();
                   Response.ClearHeaders();
                   Response.ContentType = "application/octet-stream";
                   Response.AddHeader("Content-Disposition", "attachment; filename=" +   rdr["FileNameInClient"].ToString());
                   Response.AddHeader("Content-Type", "application/octet-stream");
                   Response.AddHeader("Content-Length", buffer.Length.ToString());
                   Response.(buffer);
                   Response.Flush();
                   Response.End();
               }
           }


Can anyone please help
Posted
Comments
ZurdoDev 3-Sep-13 13:04pm    
What's your question?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900