Stream - ReadToEnd

A Stream extension method that reads a stream to the end.

Try it

public static string FileName = "test.txt";

public static void Main()
	using (StreamReader sr = File.OpenText(FileName))
		// C# Extension Method: Stream - ReadToEnd
		string text = sr.BaseStream.ReadToEnd();

private static void SaveFile()
	var html =
    @"<!DOCTYPE html>
<h1>This is <b>bold</b> heading</h1>
<p>This is <u>underlined</u> paragraph</p>
<h2>This is <i>italic</i> heading</h2>
</html> ";

View Source
using System.IO;
using System.Security.Cryptography;
using System.Text;

public static partial class Extensions
    /// <summary>
    ///     A Stream extension method that converts the @this to a md 5 hash.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <returns>@this as a string.</returns>
    public static string ToMD5Hash(this Stream @this)
        using (MD5 md5 = MD5.Create())
            byte[] hashBytes = md5.ComputeHash(@this);
            var sb = new StringBuilder();
            foreach (byte bytes in hashBytes)

            return sb.ToString();