Solved

Save file from byte array on servermap path

Posted on 2011-02-16
1
743 Views
Last Modified: 2012-08-13
Hello Everyone,

I Want to save pdf file from byte array and want to save that file on my server map path location.

Here is my code snippet. its giving no error nor saving file. Can please anyone correct my syntax if it wrong or help me by reffering other code snippet.

 
byte[] data = (byte[])listDataset.Tables[0].Rows[0][0];

System.IO.FileStream file = System.IO.File.Create(Server.MapPath(".\\TmpImages\\"+hfFileName+".pdf "));

  file.Write(data, 0, data.Length);
  file.Close();

Open in new window

0
Comment
Question by:Arslan306
1 Comment
 
LVL 25

Accepted Solution

by:
Luis Pérez earned 500 total points
ID: 34907188
Try this:

byte[] data = (byte[])listDataset.Tables[0].Rows[0][0];

System.IO.FileStream file = new System.IO.FileStream(Server.MapPath(".\\TmpImages\\"+hfFileName+".pdf "), System.IO.FileMode.Create);

  file.Write(data, 0, data.Length);
  file.Close();
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
asp.net mvc return json 2 57
Not showing page correctly 3 31
Server Error 11 48
ASP.net Have sliders change in order 2 10
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now