Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shawnweisfeld/26d52a3de886600912bf6f5a67a07943 to your computer and use it in GitHub Desktop.
Save shawnweisfeld/26d52a3de886600912bf6f5a67a07943 to your computer and use it in GitHub Desktop.
long numberOfBuckets = 10;
var fi = new FileInfo(path);
long bucketSize = fi.Length / (numberOfBuckets - 1);
Console.WriteLine($"Length: {fi.Length:N0}");
Parallel.For(0, numberOfBuckets, (i) => {
long start = i * bucketSize;
long end = start + bucketSize -1;
Console.WriteLine($"{i}: {start:N0} -> {end:N0}");
using (FileStream fs = File.OpenRead(path))
{
fs.Seek(start, SeekOrigin.Begin);
byte[] b = new byte[1024 * 1024];
while (fs.Read(b, 0, b.Length) > 0)
{
//Do Nothing;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment