Encog.Util.DirectoryUtil.CopyFile C# (CSharp) Method

CopyFile() public static method

Copy the specified file.
public static CopyFile ( String source, String target ) : void
source String The file to copy.
target String The target of the copy.
return void
        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);
            }
        }