c# split large file into chunks April 13, 2023 by wordlinkanswers c# split large file into chunks Comment 0 public static void SplitFile(string inputFile, int chunkSize, string path)<br /> {<br /> const int BUFFER_SIZE = 20 * 1024;<br /> byte[] buffer = new byte[BUFFER_SIZE];</p> <p> using (Stream input = File.OpenRead(inputFile))<br /> {<br /> int index = 0;<br /> while (input.Position < input.Length)<br /> {<br /> using (Stream output = File.Create(path + “\\” + index))<br /> {<br /> int remaining = chunkSize, bytesRead;<br /> while (remaining > 0 && (bytesRead = input.Read(buffer, 0,<br /> Math.Min(remaining, BUFFER_SIZE))) > 0)<br /> {<br /> output.Write(buffer, 0, bytesRead);<br /> remaining -= bytesRead;<br /> }<br /> }<br /> index++;<br /> Thread.Sleep(500); // experimental; perhaps try it<br /> }<br /> }<br /> } Popularity 7/10 Helpfulness 4/10 Language csharp Source: stackoverflow.com Tags: c# chunks file Share Link to this answer Share Contributed on Feb 28 2020 Easy Eagle 0 Answers Avg Quality 2/10