Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to read an image file

How to read an image file

Scheduled Pinned Locked Moved C#
csharpdatabasetutorial
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hari_1010
    wrote on last edited by
    #1

    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

    A 1 Reply Last reply
    0
    • H Hari_1010

      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

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      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

      H 1 Reply Last reply
      0
      • A Ashfield

        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

        H Offline
        H Offline
        Hari_1010
        wrote on last edited by
        #3

        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.

        A A A 3 Replies Last reply
        0
        • H Hari_1010

          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.

          A Offline
          A Offline
          astanton1978
          wrote on last edited by
          #4

          Are you using the same byte encoding when saving and retrieving?

          1 Reply Last reply
          0
          • H Hari_1010

            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.

            A Offline
            A Offline
            Alan N
            wrote on last edited by
            #5

            Hariharan, This image you refer to, is it data that is already in Microsoft Project format or is it something you need to convert to that format prior to writing out to the .mpp file. Alan.

            1 Reply Last reply
            0
            • H Hari_1010

              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.

              A Offline
              A Offline
              Ashfield
              wrote on last edited by
              #6

              I sounds rather like the file is not in mpp format.

              Bob Ashfield Consultants Ltd

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups