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. getting bites from a file

getting bites from a file

Scheduled Pinned Locked Moved C#
helpquestion
13 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.
  • R rzvme

    I need to be able to get every bit from a file (0 and 1). How do i do this. please help

    rzvme

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

    You could try reading all the bytes and then convert this to bits.

    R 1 Reply Last reply
    0
    • A andre_swnpl

      You could try reading all the bytes and then convert this to bits.

      R Offline
      R Offline
      rzvme
      wrote on last edited by
      #3

      and how exactly do i do this

      rzvme

      S A C 3 Replies Last reply
      0
      • R rzvme

        and how exactly do i do this

        rzvme

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

        Take a look at the BinaryReader (read data from the file) and BitArray (access the data bit-wise).


        "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

        R 1 Reply Last reply
        0
        • S Stefan Troschuetz

          Take a look at the BinaryReader (read data from the file) and BitArray (access the data bit-wise).


          "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

          R Offline
          R Offline
          rzvme
          wrote on last edited by
          #5

          i tried with that but it retrives bytes (in ascii)

          rzvme

          S C 2 Replies Last reply
          0
          • R rzvme

            and how exactly do i do this

            rzvme

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

            http://www.codeproject.com/useritems/JIBitArray.asp[^]

            1 Reply Last reply
            0
            • R rzvme

              i tried with that but it retrives bytes (in ascii)

              rzvme

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

              rzvme wrote:

              but it retrives bytes

              I know. That's why I also pointed you to the BitArray class.


              "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
              • R rzvme

                and how exactly do i do this

                rzvme

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #8

                You can use the && operator to pull out each bit. myByte && 1 myByte && 2 myByte && 4 etc

                Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                R 1 Reply Last reply
                0
                • R rzvme

                  i tried with that but it retrives bytes (in ascii)

                  rzvme

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #9

                  rzvme wrote:

                  (in ascii)

                  ASCII has nothing to do with it. It returns the bytes in whatever format they are on the hard drive.

                  Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                  R 1 Reply Last reply
                  0
                  • C Christian Graus

                    rzvme wrote:

                    (in ascii)

                    ASCII has nothing to do with it. It returns the bytes in whatever format they are on the hard drive.

                    Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                    R Offline
                    R Offline
                    rzvme
                    wrote on last edited by
                    #10

                    i don't want bytes i want bits(0 and 1)

                    rzvme

                    C 1 Reply Last reply
                    0
                    • C Christian Graus

                      You can use the && operator to pull out each bit. myByte && 1 myByte && 2 myByte && 4 etc

                      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                      R Offline
                      R Offline
                      rzvme
                      wrote on last edited by
                      #11

                      how exactly do i use this??

                      rzvme

                      C 1 Reply Last reply
                      0
                      • R rzvme

                        how exactly do i use this??

                        rzvme

                        C Offline
                        C Offline
                        Christian Graus
                        wrote on last edited by
                        #12

                        Nothing reads bits. You need to take each byte and strip off the bits to get the bit you want. If your value is 10001101, then 10001101 & 1 = 1, 10001101 & 10 = 0, 10001101 & 100 = 1, etc.

                        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                        1 Reply Last reply
                        0
                        • R rzvme

                          i don't want bytes i want bits(0 and 1)

                          rzvme

                          C Offline
                          C Offline
                          Christian Graus
                          wrote on last edited by
                          #13

                          I know that, although I don't see why. My point is that what you said is wrong, ASCII has nothing to do with it.

                          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                          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