save as dialogue currupts file

save as dialogue currupts file

Page 1 of 1

1 Replies - 781 Views - Last Post: 30 July 2010 - 10:04 AM Rate Topic: -----

#1 Guest_DKV*


Reputation:

save as dialogue currupts file

Posted 30 July 2010 - 08:46 AM

I am using the following code to force save as dialogue to deliver PDF file to the client using my client portal on https. When the client saves file and tries to open it he gets error: "file is damaged and could not be repaired". But when I send the same file to client as an attachment in the email, it opens successfully.
Please let me know what is wrong in the save as dialogue code and how to correct it.
 Response.ContentType = "application/pdf";
                Response.AddHeader("content-disposition", "attachment; filename=" + FName);

                FileStream sourceFile = new FileStream(TargetFile, FileMode.Open);
                long FileSize;
                FileSize = sourceFile.Length;
                byte[] getContent = new byte[(int)FileSize];
                sourceFile.Read(getContent, 0, (int)sourceFile.Length);
                sourceFile.Close();
                Response.BinaryWrite(getContent);





Thank You.

Is This A Good Question/Topic? 0

Replies To: save as dialogue currupts file

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: save as dialogue currupts file

Posted 30 July 2010 - 10:04 AM

moved to the ASP.Net forum.

here is a snippet on how to push a file from the server to the client and show a Save As dialog box.

http://www.dreaminco...snippet4088.htm
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1