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

  • SEARCH
  • Home
  • 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 8293125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:43:27+00:00 2026-06-08T13:43:27+00:00

Im trying to read a binary file where the data I’m interested in is

  • 0

Im trying to read a binary file where the data I’m interested in is separated across the file.
Which read pattern is better? (suppose initial stream position is at byte 0)

  1. read(count=8192), seek(offset=20480, origin=Current), read(count=8192), seek(offset=12288, origin=Current)
  2. read(count=8192), seek(offset=28672, origin=Begin), read(count=8192), seek(offset=49152, origin=Begin)

Since .NET Streams enable me to choose the SeekOrigin, which seek pattern is better,
the one starting from SeekOrigin.Begin, or the one that continues seeking from
the SeekOrigin.Current position?

Does it matter? Can’t the OS just do the calculation itself and decide for me?

  • 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-06-08T13:43:29+00:00Added an answer on June 8, 2026 at 1:43 pm

    It doesn’t matter. SeekOrigin.Current is just a convenience option that helps you avoid having to keep track of the absolute position yourself. Windows already does this internally so it has no trouble converting a Current offset to a Begin offset. Which is what it really needs. How you figured that the OS could seek to 20480 and then to 12288 automatically is unclear. It can’t, Windows has no notion of a record size. A file is just a stream of bytes, there’s no structure imposed on it.

    The exact order in which you seek does matter. Your program runs fastest by visiting the file locations in order. Which is a side effect of how data is written to and then read from the disk platter, usually sequentially if the disk isn’t heavily fragmented. Something the file system cache takes advantage of, it will pre-read data from the same disk track since it is very cheap to get and fairly likely to be used. By seeking in order, you’ll maximize the odds that the data will be present in the cache. You’ll just pay for the very fast memory-to-memory copy and won’t have to wait for the disk.

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

Sidebar

Related Questions

I'm trying to read the binary data from a binary file with the code
I'm trying to read data from a binary file and put it into a
I'm trying to display image data read in from a binary file (I have
In my program, I am trying to read data from binary file, and then
Im trying to read some data from a binary file into a buffer allocated
I am trying to read in data stored in a custom binary file generated
I'm trying to read data in from a binary file and then store in
I am trying to read data from a very large binary file and process
I am trying to figure out how to read a historical binary data file.
Iam trying to read a binary file to memory and pass the starting address

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.