Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6322013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:15:11+00:00 2026-05-24T16:15:11+00:00

FileStream.Read() is defined as: public override int Read( byte[] array, int offset, int count

  • 0

FileStream.Read() is defined as:

public override int Read(
    byte[] array,
    int offset,
    int count
)

How can I read some bytes from an offset bigger than int.MaxValue?

Let’s say I have a very big file and I want to read 100MB starting from position 3147483648.

How can I do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:15:12+00:00Added an answer on May 24, 2026 at 4:15 pm

    The offset here is the offset in the array at which to start writing. In your case, just set:

    stream.Position = 3147483648;
    

    and then use Read(). The offset is most commonly used when you know you need to read [n] bytes:

    int toRead = 20, bytesRead;
    while(toRead > 0 && (bytesRead = stream.Read(buffer, offset, toRead)) > 0)
    {
        toRead -= bytesRead;
        offset += bytesRead;
    }
    if(toRead > 0) throw new EndOfStreamException();
    

    this will read exactly 20 bytes into buffer (or throw an exception). Note that Read() is not guaranteed to read all the required data in one go, hence a loop incrementing an offset is usually required.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a byte array which I got back from a FileStream.Read and I
I am trying to read data from a file stream as shown below: fileStream.Read(byteArray,
The second parameter of the FileStream.Read method is called offset but is it zero-based
With the following file reading code: using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read,
I've an XML file stored in App_Data which is only used to read some
I have a C# application and am using the FileStream class to read a
I'm using ASP.NET 4, EF 4 and FILESTREAM in SQL 2008 to add/read files
I am trying to read from a config file in ProgramFiles/MyApp but in Windows
for a FILE* stream, if I read as much data as possible, feof(stream) returns
using (FileStream fileStream = new FileStream(path)) { // do something } Now I know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.