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 740427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:30:52+00:00 2026-05-14T08:30:52+00:00

I work mainly on Windows and Windows CE based systems, where CreateFile , ReadFile

  • 0

I work mainly on Windows and Windows CE based systems, where CreateFile, ReadFile and WriteFile are the work horses, no matter if I’m in native Win32 land or in managed .Net land.

I have so far never had any obvious problem writing or reading big files in one chunk, as opposed to looping until several smaller chunks are processed. I usually delegate the IO work to a background thread that notifies me when it’s done.

But looking at file IO tutorials or “textbook examples”, I often find the “loop with small chunks” used without any explanation of why it’s used instead of the more obvious (I dare to say!) “do it all at once”.

Are there any drawbacks to the way I do that I haven’t understood?

Clarification:

By big file I compared my single chunk with the multiple chunks. The multiple chunks examples I mentioned often have chunk sizes in the order 1024 bytes on Windows CE and 10 times it on the desktop. My big files are usually binary files like camera photos from mobile phones etc. and as such in the size order 2-10 MB. Not close to 1 GB, in other words.

  • 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-14T08:30:53+00:00Added an answer on May 14, 2026 at 8:30 am

    In general, you shouldn’t assume that a stream will read all the data in one go. While for local files it may be true, it may well not work for network files… and it definitely won’t work for general network streams unless a higher level has already buffered them.

    Then there’s the matter of memory: suppose someone asks you to process a 3GB file. If you stream it, processing a chunk at a time, you’ve got no problems. If you try to read the whole thing into memory, you’re unlikely to succeed…

    In general: if you can stream it, do. Why would you want to use a less reliable and less efficient approach? For any sort of robustness you’d still have to check the return value of Read and compare it with how much you expected to read… so adding a loop doesn’t cause very much complexity. Also, if you find yourself doing this a lot you may well spot patterns which you could encapsulate into helper methods, quite possibly taking delegates to represent the custom actions being taken for processing.

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

Sidebar

Ask A Question

Stats

  • Questions 394k
  • Answers 394k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I agree that recursion is not terribly necessary here, but… May 15, 2026 at 2:26 am
  • Editorial Team
    Editorial Team added an answer Performance is pretty much it. It's a good idea, but… May 15, 2026 at 2:26 am
  • Editorial Team
    Editorial Team added an answer Yes, but you have to do it by hand. Check… May 15, 2026 at 2:26 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.