Welcome to mirror list, hosted at ThFree Co, Russian Federation.

StreamExtensions.cs « Extensions « UVtools.Core - github.com/sn4k3/UVtools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c1404e041de718cc8c5d631a1e8d73fd0cccff4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 *                     GNU AFFERO GENERAL PUBLIC LICENSE
 *                       Version 3, 19 November 2007
 *  Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 *  Everyone is permitted to copy and distribute verbatim copies
 *  of this license document, but changing it is not allowed.
 */

using System.IO;

namespace UVtools.Core.Extensions
{
    public static class StreamExtensions
    {
        /// <summary>
        /// Converts stream into byte array
        /// </summary>
        /// <param name="stream">Input</param>
        /// <returns>Byte array data</returns>
        public static byte[] ToArray(this Stream stream)
        {
            using var memoryStream = new MemoryStream();
            stream.CopyTo(memoryStream);
            return memoryStream.ToArray();
        }
    }
}