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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:15:51+00:00 2026-06-05T08:15:51+00:00

In C#, the FileStream ‘s methods Read/Write/Seek take integer in parameter. In a previous

  • 0

In C#, the FileStream‘s methods Read/Write/Seek take integer in parameter. In a previous post , I have seen a good solution to read/write files that are bigger than the virtual memory allocated to a process.

This solution works if you want to write the data from the beginning to the end. But in my case, the chunks of data I am receiving are in no particular order.

I have a code that works for files smaller than 2GB :

private void WriteChunk(byte[] data, int position, int chunkSize, int count, string path)
    {

        FileStream destination = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
        BinaryWriter writer = new BinaryWriter(destination);
        writer.Seek((int) (position*chunkSize), SeekOrigin.Begin);
        writer.Write(data, 0, count);
        writer.Close();
    }

Is there a way I can seek and write my chunks in files bigger than 2GB?

  • 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-05T08:15:53+00:00Added an answer on June 5, 2026 at 8:15 am

    Don’t use int, use long. Seek takes a long.

    You need to use long everywhere though and not just cast to int somewhere.

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

Sidebar

Related Questions

FileStream's read/write method can take only integer value as length. But FileStream object returns
I have seen this post How to correctly open a FileStream for usage with
I have this code FileStream fs = new FileStream(Scores.txt, FileMode.OpenOrCreate, FileAccess.Write); StreamWriter sw =
I have an ASP.NET website which is using a filestream to read in a
I have the following code: try { FileStream FS = new FileStream(this.InFile, FileMode.Open, FileAccess.Read);
FileStream fileStream = File.OpenWrite(@upload); while (true) { thisRead = networkStream.Read(dataByte, 0, blockSize); fileStream.Write(dataByte, 0,
The second parameter of the FileStream.Read method is called offset but is it zero-based
I have a C# application and am using the FileStream class to read a
FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read); Arguments: << path >> Debugging resource strings
I have trouble accessing filestream via SqlFileStream. Sql server and IIS7 are on different

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.