Пример #1
0
        public static byte[] GetBufferSize(FileStream fileStream)
        {
            NullChecks.FileStreams(fileStream);
            int bufferSize = 4096;

            // Use a larger buffer for bigger files
            if (fileStream.Length >= Constants.Mebibyte)
            {
                // 128 KiB
                bufferSize = 131072;
            }
            else if (bufferSize > fileStream.Length)
            {
                // Use file size as buffer for small files
                return(new byte[fileStream.Length]);
            }
            return(new byte[bufferSize]);
        }