/// <summary> /// Return the MD5 hash of part of the current <see cref="ThreadSafeStream"/> as a string /// </summary> /// <param name="start">The start position in the stream</param> /// <param name="length">The length of stream to MD5</param> /// <returns></returns> public string MD5CheckSum(long start, int length) { using (MemoryStream partialStream = new MemoryStream(length)) { lock (streamLocker) { StreamWriteWithTimeout.Write(stream, start, length, partialStream, 8000, 1000, 500); return(MD5Stream(partialStream)); } } }
/// <summary> /// Copies data specified by start and length properties from internal stream to the provided stream. /// </summary> /// <param name="destinationStream">The destination stream to write to</param> /// <param name="startPosition"></param> /// <param name="length"></param> /// <param name="writeBufferSize">The buffer size to use for copying stream contents</param> /// <param name="minTimeoutMS">The minimum time allowed for any sized copy</param> /// <param name="timeoutMSPerKBWrite">The timouts in milliseconds per KB to write</param> /// <returns>The average time in milliseconds per byte written</returns> public double CopyTo(Stream destinationStream, long startPosition, long length, int writeBufferSize, double timeoutMSPerKBWrite = 1000, int minTimeoutMS = 500) { lock (streamLocker) return(StreamWriteWithTimeout.Write(stream, startPosition, length, destinationStream, writeBufferSize, timeoutMSPerKBWrite, minTimeoutMS)); }