Is it possible to cache a binary file in .NET and do normal file operations on cached file?
Well, you can of course read the file into a byte[] array and start working on it. And if you want to use a stream you can copy your FileStream into a MemoryStream and start working with it - like:
public static void CopyStream( Stream input, Stream output )
{
var buffer = new byte[32768];
int readBytes;
while( ( readBytes = input.Read( buffer, 0, buffer.Length ) ) > 0 )
{
output.Write( buffer, 0, readBytes );
}
}
If you are concerned about performance - well, normally the build-in mechanisms of the different file access methods should be enough.