Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# split large file into chunks

public static void SplitFile(string inputFile, int chunkSize, string path)
{
    const int BUFFER_SIZE = 20 * 1024;
    byte[] buffer = new byte[BUFFER_SIZE];

    using (Stream input = File.OpenRead(inputFile))
    {
        int index = 0;
        while (input.Position < input.Length)
        {
            using (Stream output = File.Create(path + "" + index))
            {
                int remaining = chunkSize, bytesRead;
                while (remaining > 0 && (bytesRead = input.Read(buffer, 0,
                        Math.Min(remaining, BUFFER_SIZE))) > 0)
                {
                    output.Write(buffer, 0, bytesRead);
                    remaining -= bytesRead;
                }
            }
            index++;
            Thread.Sleep(500); // experimental; perhaps try it
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: serial number unity pro 
Csharp :: set file to read only C# 
Csharp :: defining vectors in c# 
Csharp :: Unity rainbow color changing object 
Csharp :: mysql: [Warning] Using a password on the command line interface can be insecure. 
Csharp :: same click event diffrenet buttonms c# 
Csharp :: unity master volume changer 
Csharp :: unity camera fade to black 
Csharp :: string in c# 
Csharp :: C# max rand 
Csharp :: how to get mouse position c# 
Csharp :: serilog .net 6 
Csharp :: c# for 
Csharp :: c# shorthand if statement without else 
Csharp :: c# split include separators 
Csharp :: remove from list based on condition c# 
Csharp :: c# callback param 
Csharp :: C# System.nanoTime 
Csharp :: c# list string where 
Csharp :: go right unity 
Csharp :: upload a file selenium c# 
Csharp :: unity inspector draw line 
Csharp :: c# get every point in a line in matrix 
Csharp :: c# internalsvisibleto 
Csharp :: invalidoperationexception c# ui thread 
Csharp :: c# dictionary check if value exists 
Csharp :: Reading emails from Gmail in C# 
Csharp :: entityframework index 
Csharp :: encode pdf file to base64 c# 
Csharp :: c# read huge file 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =