While working on some XSD validation code today, I found that I needed to load a couple of text files into strings to unit test. I’d forgotten how I’d done this before, but I googled the answer with this search term:
The top result (at least as of today), gave me the answer I needed. I’ve reproduced it as the following function:
Update: Ed Poore let me know in a comment that the .NET Framework contains a method that does this already. System.IO.File.ReadAllText(path) does the same thing, so you can completely ignore the method above.