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. Stream Write Problems

Stream Write Problems

Scheduled Pinned Locked Moved C#
data-structuresperformancehelpquestion
4 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.
  • G Offline
    G Offline
    gekoscan
    wrote on last edited by
    #1

    I have a memorystream full of data. I try and use the MemoryStream.Write(byte[],0,MemoryStream.Length) and it fills my byte array up with all zero's almost like it never copied. I can verify there is data in the MemoryStream. The position of the memory stream is at 0 so that's not it.... Can anyone help me? I just don't get it. Thanks very much, Steve Nelson

    L Richard DeemingR 2 Replies Last reply
    0
    • G gekoscan

      I have a memorystream full of data. I try and use the MemoryStream.Write(byte[],0,MemoryStream.Length) and it fills my byte array up with all zero's almost like it never copied. I can verify there is data in the MemoryStream. The position of the memory stream is at 0 so that's not it.... Can anyone help me? I just don't get it. Thanks very much, Steve Nelson

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Whats the position of the memory stream? Did you set it back to 0? I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02

      1 Reply Last reply
      0
      • G gekoscan

        I have a memorystream full of data. I try and use the MemoryStream.Write(byte[],0,MemoryStream.Length) and it fills my byte array up with all zero's almost like it never copied. I can verify there is data in the MemoryStream. The position of the memory stream is at 0 so that's not it.... Can anyone help me? I just don't get it. Thanks very much, Steve Nelson

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #3

        Write(byte[] buffer, int offset, int count) Writes a block of bytes to the current stream using data read from buffer. Read(byte[] buffer, int offset, int count) Reads a block of bytes from the current stream and writes the data to buffer. Your code is copying the contents of the buffer - which will be zero - to the stream. It sounds like you want to copy the contents of the stream to the buffer, in which case you need to use the Read method.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        L 1 Reply Last reply
        0
        • Richard DeemingR Richard Deeming

          Write(byte[] buffer, int offset, int count) Writes a block of bytes to the current stream using data read from buffer. Read(byte[] buffer, int offset, int count) Reads a block of bytes from the current stream and writes the data to buffer. Your code is copying the contents of the buffer - which will be zero - to the stream. It sounds like you want to copy the contents of the stream to the buffer, in which case you need to use the Read method.


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          hehe, didn't even notice that :) I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02

          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