As you said Revit file format is a Structired Storage document and information you need is stored in the BasicFileInfo stream.
Here is the full console application demonstrating how to extract BasicFileInfo Data
Unfortunately I don't know the format of the BasicFileInfoStream. But if you read it as string you can get version in which file was created.
Read the only BasicFileInfo is much better than read the whole file. Imagine if the Revit project is over 500 MB or more. When you call
string fileContents = streamReader.ReadToEnd();
you write the whole file to the memory.
Also, Regular expression on the huge file works slow.
I think you should use
var rawString = System.Text.Encoding.Unicode.GetString(rawData);
from my sample and use Regex in the rawString instead the whole file.
Hope it helps.
UPDATED:
I completely forgot.
In the Revit 2013 you can use SavedInCurrentVersion
property of the BasicFileInfo
class to determine whether a file was saved in current Revit version or not. If you want to get version in which file was saved (as in your question caption) you can use SavedInVersion
property of the same class. You can use the BasicFileInfo.Extract
method to get the BasicFileInfo
.