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. Write binaryfile to table/dataset and then to XMLFile ....

Write binaryfile to table/dataset and then to XMLFile ....

Scheduled Pinned Locked Moved C#
question
5 Posts 3 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.
  • M Offline
    M Offline
    MaWeRic
    wrote on last edited by
    #1

    I put a binary file into a table in a dataset. I then write my dataset as a XMLfile using DataSet.WriteXML When I look at the field with my file-content I have a string wich look like this ... "/9j/4AAQSkZJRgABAgEAYABgAAD/7ABzRHVja3kAAQAEAAAAPAADAF4AAAAtA<" What kind of string is that? How can I get it without using dataset/writexml to get it? I have a special solution where I need to get that string. Please hekp // henrik

    G T 2 Replies Last reply
    0
    • M MaWeRic

      I put a binary file into a table in a dataset. I then write my dataset as a XMLfile using DataSet.WriteXML When I look at the field with my file-content I have a string wich look like this ... "/9j/4AAQSkZJRgABAgEAYABgAAD/7ABzRHVja3kAAQAEAAAAPAADAF4AAAAtA<" What kind of string is that? How can I get it without using dataset/writexml to get it? I have a special solution where I need to get that string. Please hekp // henrik

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      How are you storing your binary file before putting in the datatable? If you store binary file in byte[] then Google for 'convert byte array to string' You can use BinaryReader class for reading binary data.

      Giorgi Dalakishvili #region signature my articles #endregion

      1 Reply Last reply
      0
      • M MaWeRic

        I put a binary file into a table in a dataset. I then write my dataset as a XMLfile using DataSet.WriteXML When I look at the field with my file-content I have a string wich look like this ... "/9j/4AAQSkZJRgABAgEAYABgAAD/7ABzRHVja3kAAQAEAAAAPAADAF4AAAAtA<" What kind of string is that? How can I get it without using dataset/writexml to get it? I have a special solution where I need to get that string. Please hekp // henrik

        T Offline
        T Offline
        The Nightcoder
        wrote on last edited by
        #3

        I think the DataSet uses Base64 encoding when it serializes binary fields into XML. I may be wrong, but it is the most common way to encode binary data in XML. To read it, you could use a System.Xml.XmlReader (and its ReadElementContentAsBase64 method once you've located the correct field). However, the normal way to do it would be to recreate the dataset from the XML file, though (using ReadXml on a new dataset)... If for some reason you don't want to use the system-provided XML tools and instead want to read the file as text and do your own decoding, you can either google for base64 or use, for example, System.Convert.FromBase64String.

        Peter the small turnip (1) It Has To Work. --RFC 1925[^]

        M 1 Reply Last reply
        0
        • T The Nightcoder

          I think the DataSet uses Base64 encoding when it serializes binary fields into XML. I may be wrong, but it is the most common way to encode binary data in XML. To read it, you could use a System.Xml.XmlReader (and its ReadElementContentAsBase64 method once you've located the correct field). However, the normal way to do it would be to recreate the dataset from the XML file, though (using ReadXml on a new dataset)... If for some reason you don't want to use the system-provided XML tools and instead want to read the file as text and do your own decoding, you can either google for base64 or use, for example, System.Convert.FromBase64String.

          Peter the small turnip (1) It Has To Work. --RFC 1925[^]

          M Offline
          M Offline
          MaWeRic
          wrote on last edited by
          #4

          Yeap ... It is base64 ... Found the solution yesterday ... Thanks // HenrikDaSwede :D

          T 1 Reply Last reply
          0
          • M MaWeRic

            Yeap ... It is base64 ... Found the solution yesterday ... Thanks // HenrikDaSwede :D

            T Offline
            T Offline
            The Nightcoder
            wrote on last edited by
            #5

            MaWeRic wrote:

            Thanks // HenrikDaSwede

            We are the turnips[^]. You will be assimilated. Resistance is futile... :-)

            Peter the small turnip (1) It Has To Work. --RFC 1925[^]

            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