Click here to Skip to main content
15,667,847 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a large file of 8 GB and want to read in 8 parts but problem is i don't know how to read file in parts can someone help me here.

Note:-File reading here refers to converting file into byte array which can be achieved like this:-

Thanks in advance

1 solution

Use Stream.Read[^] instead:
byte[] buffer = new buffer[blockSize];
FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
    int count;
    while ((count = fileStream.Read(buffer, sum, blockSize)) > 0)
        ... do something with the block.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900