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. what is the maximum size

what is the maximum size

Scheduled Pinned Locked Moved C#
questiondata-structures
9 Posts 5 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.
  • J Offline
    J Offline
    Joe Rozario
    wrote on last edited by
    #1

    Dear friends, small Clarification what is the maximum size of byte array? if i write like this ( for 2 gb file will it handle?) byte[] bdata = System.IO.File.ReadAllBytes("MyFileName.doc"); Why the Stream.Read(buffer[],offset,"length") "Length" as "int" not a "double" (if it more then 2gb File How can i specify the length "becase the integer maximum value is (2gb -1 byte)... if i want to read the last 10 bytes in more then 2gb file how can i read? any idea? link?.. By joe.I

    T U L L 4 Replies Last reply
    0
    • J Joe Rozario

      Dear friends, small Clarification what is the maximum size of byte array? if i write like this ( for 2 gb file will it handle?) byte[] bdata = System.IO.File.ReadAllBytes("MyFileName.doc"); Why the Stream.Read(buffer[],offset,"length") "Length" as "int" not a "double" (if it more then 2gb File How can i specify the length "becase the integer maximum value is (2gb -1 byte)... if i want to read the last 10 bytes in more then 2gb file how can i read? any idea? link?.. By joe.I

      T Offline
      T Offline
      Thomas Krojer
      wrote on last edited by
      #2

      Take a look at the StreamReader Class.

      J 1 Reply Last reply
      0
      • J Joe Rozario

        Dear friends, small Clarification what is the maximum size of byte array? if i write like this ( for 2 gb file will it handle?) byte[] bdata = System.IO.File.ReadAllBytes("MyFileName.doc"); Why the Stream.Read(buffer[],offset,"length") "Length" as "int" not a "double" (if it more then 2gb File How can i specify the length "becase the integer maximum value is (2gb -1 byte)... if i want to read the last 10 bytes in more then 2gb file how can i read? any idea? link?.. By joe.I

        U Offline
        U Offline
        User 2183100
        wrote on last edited by
        #3

        Please don't read a 2gb file all at once. Thats just insane. Read it a little bit at a time, say, 1 mb or 10 mb, or whatever. Like the other guy said, check out StreamReader.

        J 1 Reply Last reply
        0
        • T Thomas Krojer

          Take a look at the StreamReader Class.

          J Offline
          J Offline
          Joe Rozario
          wrote on last edited by
          #4

          Thank you friend, Thanks for Your replay ...... i made small mistake .... :-\ thank you. by joe

          1 Reply Last reply
          0
          • U User 2183100

            Please don't read a 2gb file all at once. Thats just insane. Read it a little bit at a time, say, 1 mb or 10 mb, or whatever. Like the other guy said, check out StreamReader.

            J Offline
            J Offline
            Joe Rozario
            wrote on last edited by
            #5

            Thank you friend, Thanks for Your replay ...... i made small mistake .... :-\ i am not reading 2G file at time i am reading 100kb at time ...anyhow thanks for your suggestion. thank you. by joe

            1 Reply Last reply
            0
            • J Joe Rozario

              Dear friends, small Clarification what is the maximum size of byte array? if i write like this ( for 2 gb file will it handle?) byte[] bdata = System.IO.File.ReadAllBytes("MyFileName.doc"); Why the Stream.Read(buffer[],offset,"length") "Length" as "int" not a "double" (if it more then 2gb File How can i specify the length "becase the integer maximum value is (2gb -1 byte)... if i want to read the last 10 bytes in more then 2gb file how can i read? any idea? link?.. By joe.I

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              IIRC it depends on 32 vs 64 bit. But, in any case, will you really be happy if one program fills up all of most (or at least a sizable chunk) of your RAM? Btw, surely you mean a long not a double

              J 1 Reply Last reply
              0
              • J Joe Rozario

                Dear friends, small Clarification what is the maximum size of byte array? if i write like this ( for 2 gb file will it handle?) byte[] bdata = System.IO.File.ReadAllBytes("MyFileName.doc"); Why the Stream.Read(buffer[],offset,"length") "Length" as "int" not a "double" (if it more then 2gb File How can i specify the length "becase the integer maximum value is (2gb -1 byte)... if i want to read the last 10 bytes in more then 2gb file how can i read? any idea? link?.. By joe.I

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                Hi, AFAIK array sizes are limited to something like 2G-1. However, assuming you only need part of the content of a binary (i.e. non-text) file, you can: - get the File.Length, which is a long; - get a stream for reading the file, with File.Open; - seek a position in the file, say length-10, using FileStream.Seek; - and read part of the file into an array, using FileStream.Read; - finally close/dispose everything. So for getting the end of the file, there is no need whatsoever to read everything! :)

                Luc Pattyn [Forum Guidelines] [My Articles]


                I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


                J 1 Reply Last reply
                0
                • L Lost User

                  IIRC it depends on 32 vs 64 bit. But, in any case, will you really be happy if one program fills up all of most (or at least a sizable chunk) of your RAM? Btw, surely you mean a long not a double

                  J Offline
                  J Offline
                  Joe Rozario
                  wrote on last edited by
                  #8

                  Thanks for your replay....

                  harold aptroot wrote:

                  or at least a sizable chunk

                  that's what i was trying ....

                  harold aptroot wrote:

                  surely you mean a long not a double

                  yes i was mistaken that is long Thank you so much :) :) :) :) by joe

                  1 Reply Last reply
                  0
                  • L Luc Pattyn

                    Hi, AFAIK array sizes are limited to something like 2G-1. However, assuming you only need part of the content of a binary (i.e. non-text) file, you can: - get the File.Length, which is a long; - get a stream for reading the file, with File.Open; - seek a position in the file, say length-10, using FileStream.Seek; - and read part of the file into an array, using FileStream.Read; - finally close/dispose everything. So for getting the end of the file, there is no need whatsoever to read everything! :)

                    Luc Pattyn [Forum Guidelines] [My Articles]


                    I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


                    J Offline
                    J Offline
                    Joe Rozario
                    wrote on last edited by
                    #9

                    Thank you friend.... i was doing the same .... thanks for the explantion ... i did not notice that Seek position is (Long)

                    Luc Pattyn wrote:

                    seek a position in the file, say length-10, using FileStream.Seek

                    now my program works fine ... :) :) :-D by joe

                    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