using System;
using System.IO;
public class splitFile
{
public static void Main(string[] args)
{
FileStream myFile;
FileStream myNewFile;
string nameFile;
int BUFFER_SIZE;
int amountRead;
int count = 1;
if (args.Length == 2)
{
nameFile = args[0];
BUFFER_SIZE = Convert.ToInt32(args[1]);
byte[] data = new byte[BUFFER_SIZE];
try
{
myFile = File.OpenRead(nameFile);
do
{
amountRead = myFile.Read(data, 0, BUFFER_SIZE);
myNewFile = File.Create(nameFile + count.ToString("000"));
myNewFile.Write(data, 0, amountRead);
count++;
myNewFile.Close();
}
while (amountRead == BUFFER_SIZE);
myFile.Close();
}
catch (Exception fileError)
{
Console.WriteLine("ERROR has ocurred while executing: " + fileError.Message);
}
}
else
{
Console.WriteLine("The parameters are incorrects");
Console.WriteLine("usage: splitfile namefile sizeinbytes");
}
}
}