Aliyun.OSS.Util.IoUtils.WriteTo C# (CSharp) Method

WriteTo() public static method

public static WriteTo ( Stream orignStream, Stream destStream, long totalSize ) : long
orignStream System.IO.Stream
destStream System.IO.Stream
totalSize long
return long
        public static long WriteTo(Stream orignStream, Stream destStream, long totalSize)
        {
            var buffer = new byte[BufferSize];

            long alreadyRead = 0;
            while (alreadyRead < totalSize)
            {
                var readSize = orignStream.Read(buffer, 0, BufferSize);
                if (readSize <= 0)
                    break;

                if (alreadyRead + readSize > totalSize)
                    readSize = (int) (totalSize - alreadyRead);
                alreadyRead += readSize;
                destStream.Write(buffer, 0, readSize);
            }
            destStream.Flush();

            return alreadyRead;
        }

Same methods

IoUtils::WriteTo ( Stream src, Stream dest ) : void
IoUtils