AGS.Editor.DataFileWriter.CopyFileAcross C# (CSharp) Метод

CopyFileAcross() статический приватный Метод

static private CopyFileAcross ( Stream instream, Stream copystream, long leftforthis ) : int
instream Stream
copystream Stream
leftforthis long
Результат int
        static int CopyFileAcross(Stream instream, Stream copystream, long leftforthis)
        {
            int success = 1;
            byte[] diskbuffer = new byte[NativeConstants.CHUNKSIZE + 10];
            while (leftforthis > 0)
            {
                if (leftforthis > NativeConstants.CHUNKSIZE)
                {
                    instream.Read(diskbuffer, 0, NativeConstants.CHUNKSIZE);
                    try
                    {
                        copystream.Write(diskbuffer, 0, NativeConstants.CHUNKSIZE);
                    }
                    catch
                    {
                        success = 0;
                    }
                    finally
                    {
                        success = 1;
                    }
                    leftforthis -= NativeConstants.CHUNKSIZE;
                }
                else
                {
                    instream.Read(diskbuffer, 0, (int)leftforthis);
                    try
                    {
                        copystream.Write(diskbuffer, 0, (int)leftforthis);
                    }
                    catch
                    {
                        success = 0;
                    }
                    finally
                    {
                        success = 1;
                    }
                    leftforthis = 0;
                }
                if (success < 1) break;
            }
            return success;
        }