public static void CopyFile(String source, String target)
{
try
{
var buffer = new byte[BufferSize];
// open the files before the copy
Stream inFile = new FileStream(source, FileMode.Open);
Stream outFile = new FileStream(target, FileMode.OpenOrCreate);
// perform the copy
int packetSize = 0;
while (packetSize != -1)
{
packetSize = inFile.Read(buffer, 0, buffer.Length);
if (packetSize != -1)
{
outFile.Write(buffer, 0, packetSize);
}
}
// close the files after the copy
inFile.Close();
outFile.Close();
}
catch (IOException e)
{
throw new EncogError(e);
}
}