How to read an image file
-
Hi All, My requirement is to read an image file from database and to save it as project file (.mpp) file in C# .Net Many thanks in advance. Thanks and Regards, Hariharan C
-
Ok, thats your requirement, where's your code? Write something, post it when it doesn't work and maybe someone will help you.
Bob Ashfield Consultants Ltd
Hi All, I am able to read the file from database and save it as a mpp file. But when i tried to open in MS Project, its saying the following error, "Project cannot recognize this file format" The following is my code, DataSet ds = new DataSet(); SqlConnection con = new SqlConnection("data source=hariharan; initial catalog=ProjectServer; integrated security=true"); con.Open(); SqlCommand cmd = new SqlCommand("select reserved_binary_Data from MSP_PROJECTS where proj_name = 'TestProject.Published'", con); cmd.CommandType = CommandType.Text; SqlDataAdapter ada = new SqlDataAdapter(cmd); ada.Fill(ds); byte[] contentArray = (byte[])ds.Tables[0].Rows[0][0]; int len = contentArray.Length; FileStream docStream = new FileStream("C:\\testing.mpp", FileMode.CreateNew, FileAccess.ReadWrite); docStream.Write(contentArray, 0, len); docStream.Close(); con.Close(); Regards, Hariharan.
-
Hi All, I am able to read the file from database and save it as a mpp file. But when i tried to open in MS Project, its saying the following error, "Project cannot recognize this file format" The following is my code, DataSet ds = new DataSet(); SqlConnection con = new SqlConnection("data source=hariharan; initial catalog=ProjectServer; integrated security=true"); con.Open(); SqlCommand cmd = new SqlCommand("select reserved_binary_Data from MSP_PROJECTS where proj_name = 'TestProject.Published'", con); cmd.CommandType = CommandType.Text; SqlDataAdapter ada = new SqlDataAdapter(cmd); ada.Fill(ds); byte[] contentArray = (byte[])ds.Tables[0].Rows[0][0]; int len = contentArray.Length; FileStream docStream = new FileStream("C:\\testing.mpp", FileMode.CreateNew, FileAccess.ReadWrite); docStream.Write(contentArray, 0, len); docStream.Close(); con.Close(); Regards, Hariharan.
Are you using the same byte encoding when saving and retrieving?
-
Hi All, I am able to read the file from database and save it as a mpp file. But when i tried to open in MS Project, its saying the following error, "Project cannot recognize this file format" The following is my code, DataSet ds = new DataSet(); SqlConnection con = new SqlConnection("data source=hariharan; initial catalog=ProjectServer; integrated security=true"); con.Open(); SqlCommand cmd = new SqlCommand("select reserved_binary_Data from MSP_PROJECTS where proj_name = 'TestProject.Published'", con); cmd.CommandType = CommandType.Text; SqlDataAdapter ada = new SqlDataAdapter(cmd); ada.Fill(ds); byte[] contentArray = (byte[])ds.Tables[0].Rows[0][0]; int len = contentArray.Length; FileStream docStream = new FileStream("C:\\testing.mpp", FileMode.CreateNew, FileAccess.ReadWrite); docStream.Write(contentArray, 0, len); docStream.Close(); con.Close(); Regards, Hariharan.
-
Hi All, I am able to read the file from database and save it as a mpp file. But when i tried to open in MS Project, its saying the following error, "Project cannot recognize this file format" The following is my code, DataSet ds = new DataSet(); SqlConnection con = new SqlConnection("data source=hariharan; initial catalog=ProjectServer; integrated security=true"); con.Open(); SqlCommand cmd = new SqlCommand("select reserved_binary_Data from MSP_PROJECTS where proj_name = 'TestProject.Published'", con); cmd.CommandType = CommandType.Text; SqlDataAdapter ada = new SqlDataAdapter(cmd); ada.Fill(ds); byte[] contentArray = (byte[])ds.Tables[0].Rows[0][0]; int len = contentArray.Length; FileStream docStream = new FileStream("C:\\testing.mpp", FileMode.CreateNew, FileAccess.ReadWrite); docStream.Write(contentArray, 0, len); docStream.Close(); con.Close(); Regards, Hariharan.