My brain often follows the following path when writing code to operate on a File:
And so I end up passing around instances of URI which is actually a pretty good solution. When I need to unit test, I use this library to pass self-contained bits of data around without needing to write temp files and then use file: URIs or similar.
Data URIs are defined by RFC 2397. Ian Hixson maintains the Data URI kitchen wherein you can play with Data URIs.
Usage:
DataWebRequest.DataWebRequest.Register(); //only needs to be called once //now we can use the data: uri scheme System.Net.WebClient wc = new System.Net.WebClient(); String s = wc.DownloadString("data:text/plain,data data"); //s is now "data data"
The release dll has no dependencies. You will need NUnit to run the unit tests. This library has been placed in the public domain.