Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I am downloading a dynamically generated pdf file to server folder.However it is working fine.But the problem is that while the pdf file is downloaded ,a byte file is also downloaded alongwith pdf file with 0kb. Can anyone help me please.Any hep will be really appreciated.

What I have tried:

pdfDoc.Add(pdfTable);
               pdfDoc.Close();
               string newfile = Name + "_" + DateTime.Now.ToString("dd-MMM-yyyy") + ".pdf";

               String path_name = "~/Sample/SampleReports/";
               var pdfPath = Path.Combine(Server.MapPath(path_name));

               string username = "Test";
               string password = "12345";
              //String file_name_pdf = "Test.pdf";

              var pdfContents = mStream.ToArray();
              File.WriteAllBytes(Path.Combine(pdfPath, newfile), pdfContents);
              WebRequest request = WebRequest.Create(Server.MapPath("~/Sample/SampleReports/" + pdfContents));
               request.Method = WebRequestMethods.Ftp.UploadFile;

               request.Credentials = new NetworkCredential(username, password);
               Stream reqStream = request.GetRequestStream();
               reqStream.Close();
Posted
Updated 28-Nov-17 3:41am

1 solution

You are appending a byte array to a path:
C#
WebRequest request = WebRequest.Create(Server.MapPath("~/Sample/SampleReports/" + pdfContents));
 
Share this answer
 

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