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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Byte = Stream.Read

Byte = Stream.Read

Scheduled Pinned Locked Moved C#
questiondata-structureshelp
3 Posts 3 Posters 1 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
    hung_ngole
    wrote on last edited by
    #1

    Hi, I have a System.IO.Stream, now I want to get all data from that stream into a Byte array! I try with the ReadToEnd() but it return the String type (=>problem with image data). I try to read the length of the stream, but it return -1. If I read byte to byte, it's OK but my program will be slow! How can I do? Thanks, Hung. Hung

    S N 2 Replies Last reply
    0
    • H hung_ngole

      Hi, I have a System.IO.Stream, now I want to get all data from that stream into a Byte array! I try with the ReadToEnd() but it return the String type (=>problem with image data). I try to read the length of the stream, but it return -1. If I read byte to byte, it's OK but my program will be slow! How can I do? Thanks, Hung. Hung

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      Try the Stream.Read method[^].


      "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

      www.troschuetz.de

      1 Reply Last reply
      0
      • H hung_ngole

        Hi, I have a System.IO.Stream, now I want to get all data from that stream into a Byte array! I try with the ReadToEnd() but it return the String type (=>problem with image data). I try to read the length of the stream, but it return -1. If I read byte to byte, it's OK but my program will be slow! How can I do? Thanks, Hung. Hung

        N Offline
        N Offline
        Nader Elshehabi
        wrote on last edited by
        #3

        Hello Try this:- string input = MyStream.ReadToTheEnd(); byte[] ByteArray = System.Text.Encoding.Default.GetBytes(input); Regards:rose:

        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