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. Web Development
  3. ASP.NET
  4. Something goes wrong with converting bytes

Something goes wrong with converting bytes

Scheduled Pinned Locked Moved ASP.NET
databasequestion
3 Posts 2 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.
  • T Offline
    T Offline
    TurokHan
    wrote on last edited by
    #1

    I'm trying to create a progressbar for downloading. I can catch the raw postback info: -----------------------------7d4204b3f043c Content-Disposition: form-data; name="__VIEWSTATE" dDwtMTI3OTMzNDM4NDs7Pp/0hcX8BMxmXMGOJJC27tgAEod8 -----------------------------7d4204b3f043c Content-Disposition: form-data; name="file"; filename="P:\logo.gif" Content-Type: image/gif GIF89an (lot of code for gif image) -----------------------------7d4204b3f043c-- Now i need to filter out the headers to be able to save it to a gif image(on disk). I tryed this by converting everything to string and filtering out the info. This worked, but for some reason my imagedata gets corrupted. Original: 00000000h: 47 49 46 38 39 61 14 01 6E 00 F7 00 00 F7 F7 F7 ; GIF89a..n.÷..÷÷÷ 00000010h: FF FB FF E7 E7 E7 D6 D3 D6 EF EB EF CE CB CE AD ; ÿûÿçççÖÓÖïëïÎËέ 00000020h: 14 00 DE DB DE 18 45 AD 18 49 B5 10 34 84 10 3C ; ..ÞÛÞ.E­.Iµ.4„.< After filter: 00000000h: 47 49 46 38 39 61 14 01 6E 00 77 00 00 77 77 77 ; GIF89a..n.w..www 00000010h: 7F 7B 7F 67 67 67 56 53 56 6F 6B 6F 4E 4B 4E 2D ; {gggVSVokoNKN- 00000020h: 14 00 5E 5B 5E 18 45 2D 18 49 35 10 34 04 10 3C ; ..^[^.E-.I5.4..< I'm probably doings something wrong in converting, or because i'm cutting in the string. Anybody know why this happens?

    T M 2 Replies Last reply
    0
    • T TurokHan

      I'm trying to create a progressbar for downloading. I can catch the raw postback info: -----------------------------7d4204b3f043c Content-Disposition: form-data; name="__VIEWSTATE" dDwtMTI3OTMzNDM4NDs7Pp/0hcX8BMxmXMGOJJC27tgAEod8 -----------------------------7d4204b3f043c Content-Disposition: form-data; name="file"; filename="P:\logo.gif" Content-Type: image/gif GIF89an (lot of code for gif image) -----------------------------7d4204b3f043c-- Now i need to filter out the headers to be able to save it to a gif image(on disk). I tryed this by converting everything to string and filtering out the info. This worked, but for some reason my imagedata gets corrupted. Original: 00000000h: 47 49 46 38 39 61 14 01 6E 00 F7 00 00 F7 F7 F7 ; GIF89a..n.÷..÷÷÷ 00000010h: FF FB FF E7 E7 E7 D6 D3 D6 EF EB EF CE CB CE AD ; ÿûÿçççÖÓÖïëïÎËέ 00000020h: 14 00 DE DB DE 18 45 AD 18 49 B5 10 34 84 10 3C ; ..ÞÛÞ.E­.Iµ.4„.< After filter: 00000000h: 47 49 46 38 39 61 14 01 6E 00 77 00 00 77 77 77 ; GIF89a..n.w..www 00000010h: 7F 7B 7F 67 67 67 56 53 56 6F 6B 6F 4E 4B 4E 2D ; {gggVSVokoNKN- 00000020h: 14 00 5E 5B 5E 18 45 2D 18 49 35 10 34 04 10 3C ; ..^[^.E-.I5.4..< I'm probably doings something wrong in converting, or because i'm cutting in the string. Anybody know why this happens?

      T Offline
      T Offline
      TurokHan
      wrote on last edited by
      #2

      I'm thinking that it is the bytes --> string --> bytes convertion that currupts the info, so i was wondering if anyone knows a way in wich I can parse these headers out, just using byte[]. I think i would need a sort of byte[].Split(byte[] originalArray, byte[] splitOnFindingThis); Or is there a better way? I was also thinking, maybe i could split on \r\n, but that would also split up the file itself, so i don't think that is a good idea.

      1 Reply Last reply
      0
      • T TurokHan

        I'm trying to create a progressbar for downloading. I can catch the raw postback info: -----------------------------7d4204b3f043c Content-Disposition: form-data; name="__VIEWSTATE" dDwtMTI3OTMzNDM4NDs7Pp/0hcX8BMxmXMGOJJC27tgAEod8 -----------------------------7d4204b3f043c Content-Disposition: form-data; name="file"; filename="P:\logo.gif" Content-Type: image/gif GIF89an (lot of code for gif image) -----------------------------7d4204b3f043c-- Now i need to filter out the headers to be able to save it to a gif image(on disk). I tryed this by converting everything to string and filtering out the info. This worked, but for some reason my imagedata gets corrupted. Original: 00000000h: 47 49 46 38 39 61 14 01 6E 00 F7 00 00 F7 F7 F7 ; GIF89a..n.÷..÷÷÷ 00000010h: FF FB FF E7 E7 E7 D6 D3 D6 EF EB EF CE CB CE AD ; ÿûÿçççÖÓÖïëïÎËέ 00000020h: 14 00 DE DB DE 18 45 AD 18 49 B5 10 34 84 10 3C ; ..ÞÛÞ.E­.Iµ.4„.< After filter: 00000000h: 47 49 46 38 39 61 14 01 6E 00 77 00 00 77 77 77 ; GIF89a..n.w..www 00000010h: 7F 7B 7F 67 67 67 56 53 56 6F 6B 6F 4E 4B 4E 2D ; {gggVSVokoNKN- 00000020h: 14 00 5E 5B 5E 18 45 2D 18 49 35 10 34 04 10 3C ; ..^[^.E-.I5.4..< I'm probably doings something wrong in converting, or because i'm cutting in the string. Anybody know why this happens?

        M Offline
        M Offline
        minhpc_bk
        wrote on last edited by
        #3

        I also think the problem happens due to data conversion. Here is just my humble opinion: you can try again with the base64 encoding with help from the System.Convert class. When converting data from bytes to string, you can make use of the System.Convert.ToBase64String method, then you can filter out data. When converting data back to bytes, you can use the System.Convert.FromBase64String method. Hope that helps.

        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