Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Save file from byte array on servermap path

Posted on 2011-02-16
1
Medium Priority
?
784 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 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

885 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