Solved

Save file from byte array on servermap path

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to count occurrences of each item in an array.

705 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

13 Experts available now in Live!

Get 1:1 Help Now