src/packages/EmbedIO.Testing/StockResource.cs
/// <summary>
/// <para>Gets a range of bytes from a resource's contents.</para>
/// <para>The range must be specified the same way as in HTTP <c>Range</c> headers,
/// i.e. with a starting offset and an inclusive upper bound; for example,
/// if <paramref name="start"/>is 200 and <paramref name="upperBound"/> is 299
/// then 100 bytes are returned, starting from the 201st byte (as indexes are 0-based).</para>
/// </summary>
/// <param name="path">The path to the resource.</param>
/// <param name="start">The starting offset of the range to return.</param>
/// <param name="upperBound">The inclusive upper bound of the range to return.</param>
/// <returns>An array of bytes containing the specified range of the resource's contents,
/// or <see langword="null"/> if the range is not valid.</returns>
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException"><paramref name="path"/> is an empty string.</exception>
/// <exception cref="FileNotFoundException"><paramref name="path"/> was not found.</exception>
Gets a range of bytes from a resource's contents.The range must be specified the same way as in HTTP Rangeis 200 and  is 299
then 100 bytes are returned, starting from the 201st byte (as indexes are 0-based).
Gets a range of bytes from a resource ' s contents . The range must be specified the same way as in HTTP Rangeis 200 and is 299 then 100 bytes are returned starting from the 201st byte ( as indexes are 0 - based ) .
public static byte[]? GetByteRange(string path, int start, int upperBound)
        {
            using var stream = Open(path);
            var length = (int)stream.Length;
            if (start >= length || upperBound < start || upperBound >= length)
                return null;
            var rangeLength = upperBound - start + 1;
            var buffer = new byte[rangeLength];
            stream.Position = start;
            stream.Read(buffer, 0, rangeLength);
            return buffer;
        }
public static byte [ ] ? GetByteRange ( string path , int start , int upperBound ) { using var stream = Open ( path ) ; var length = ( int ) stream . Length ; if ( start >= length || upperBound < start || upperBound >= length ) return null ; var rangeLength = upperBound - start + 1 ; var buffer = new byte [ rangeLength ] ; stream . Position = start ; stream . Read ( buffer , 0 , rangeLength ) ; return buffer ; }
Gets a range of bytes from a resource's contents.The range must be specified the same way as in HTTP Rangeis 200 and  is 299
then 100 bytes are returned, starting from the 201st byte (as indexes are 0-based).
Gets a range of bytes from a resource ' s contents . The range must be specified the same way as in HTTP Rangeis 200 and is 299 then 100 bytes are returned starting from the 201st byte ( as indexes are 0 - based ) .
An array of bytes containing the specified range of the resource's contents,
or  if the range is not valid.
An array of bytes containing the specified range of the resource ' s contents or if the range is not valid .
None
None
was not found.
was not found .
path
string
The path to the resource.
The path to the resource .
start
int
The starting offset of the range to return.
The starting offset of the range to return .
upperBound
int
The inclusive upper bound of the range to return.
The inclusive upper bound of the range to return .