当前位置: 动力学知识库 > 问答 > 编程问答 >

sql server - PDF Error Opening Error Retrieved From Database to Virtual Folder

问题描述:

I am trying to Retrieve Binary Data [PDF] From SQL Server to My Virtual Directory:

 string filePaths = System.Web.HttpContext.Current.Server.MapPath("~/TempPDF/");

And I have the following code to Write Data Into filePath, its downloading fine but when I am trying to open in PDF its giving me error. "Adobe Reader could not open "FileName.pdf" because it is either not supported or because file has been damaged"

My Code :

string last = fileName.Substring(fileName.LastIndexOf('.') + 1);

if (last == "pdf")

{

using (System.IO.FileStream fs = new System.IO.FileStream(filePaths+fileName, System.IO.FileMode.CreateNew ))

{ // use a binary writer to write the bytes to disk

using (System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs))

{

bw.Write(Data, 0, Data.Length);

//bw.Write(Data);

bw.Flush();

bw.Close();

}

}

}

分享给朋友:
您可能感兴趣的文章:
随机阅读: