I have a C# asp.net web page which reads PDF file from Mysql database (which stores as longblob format) and open it. It works in my Localhost; the page reads the file from database and open with acrobat reader but it doesn't work in the testing server after i deploy the page. The acrobat reader doesn't open and i don't see acroRd32.exe in the taskmgr manager. I feel it is permission issue because i use process.start() which may not allow in the server but i dont see error messages. If there are permissions needs to be done in server; can anyone kindly points me the direction?
Thank You.
Here are my code:
MySqlDataReader Reader = null;
connection.Open();
MySqlCommand command = new MySqlCommand("Select Image, File_Type, File_Name from table where ImageID = " + ImageID, connection);
Reader = command.ExecuteReader();
if (Reader.Read())
{
byte[] buffer = (byte[])Reader["Image"];
System.IO.MemoryStream stream1 = new System.IO.MemoryStream(buffer, true);
stream1.Write(buffer, 0, buffer.Length);
String fileName = Reader["File_Name"].ToString();
String dirName = "C:\\thefolder\\";
if (!Directory.Exists(dirName))
{
// if not then create
Directory.CreateDirectory(dirName);
}
if (File.Exists(dirName+fileName))
File.Delete(dirName + fileName);
Directory.CreateDirectory(Path.GetDirectoryName(Reader["File_Name"].ToString()));
using (Stream file = File.Create(dirName + fileName))
{
file.Write(buffer, 0, buffer.Length);
}
Process process = new Process();
process.StartInfo.FileName = "AcroRd32.exe";
process.Start();
}
Thanks for your help, i am able to send pdf content via response. Here is the code
//Process process = new Process();
//process.StartInfo.FileName = "AcroRd32.exe";
//process.Start();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.Clear();
Response.AppendHeader("Content-Disposition", "attachment");
Response.TransmitFile(dirName + fileName);
Response.End();