I need file download code in c#

Posted by Sekar.C under C# on 3/5/2012 | Points: 10 | Views : 2581 | Status : [Member] | Replies : 4
Sir,
I need file download code in c#.
Uploaded file are stored in db how can I download specific file

I use this code in asp.net with c# code, file downloaded but first file only download others are not download

Byte[] bytes = (Byte[])dt.Rows[0]["Content"];
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.AddHeader("content-disposition", "attachment;filename="+ dt.Rows[0]["FileName"].ToString());
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();


Regard
sekar.c

Regards
Sekar.c



Responses

Posted by: Hmanjarawala on: 3/6/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,
What do you mean sekar,

you have mention:
Byte[] bytes = (Byte[])dt.Rows[0]["Content"];
means your are only fetches content of 1st file.
that's why it download content of 1st file only...

plz verify your code.


Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sekar.C on: 3/6/2012 [Member] Starter | Points: 25

Up
0
Down
hi,
ok .how can download any other file in table.

regard
sekar.c

Regards
Sekar.c

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 3/6/2012 [Member] Bronze | Points: 25

Up
0
Down
Tell me one thing,
will you get only single row every time in DataTable?

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sekar.C on: 3/6/2012 [Member] Starter | Points: 25

Up
0
Down
yes

Regards
Sekar.c

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response