Solved

Save file from byte array on servermap path

Posted on 2011-02-16
1
750 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

825 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