Create an instance of SPFile using GetFile method and pass the GUID of the file in its parameter. Then immediately call OpenBinaryStream method in the instance of spfile. It then throws a COM exception "The path specified is being used in a substitute. (Exception from HRESULT: 0x80070092)"
SPFile oSPFile = OSPWeb.GetFile("GUID of the file");
Stream oStream = oSPFile.OpenBinaryStream();
But, at the same time, the below mentioned code works fine.
string strName = OSPFile.Name;
Or even, this code works.
SPFile oSPFile = OSPWeb.GetFile("URL");
There is a method in the SPFile class called GetFileStream. This method calls the COM level method GetFileAsStream which accepts webRelativeUrl as one of the parameters. When we access a property of the file before calling the OpenStream method this method gets populated with the relative path of the file we are working with. If we directly call the method OpenBinaryStream right after we get the file though the GUID, this parameter is null and will fail with the exception:"The path specified is being used in a substitute".
PingBack from http://blog.a-foton.ru/2008/07/calling-openbinarystream-throws-com-exception-0x80070092/
you made my day.
During debugging the code works fine, but at runtime the error is raised. Seems also some kind of timing issue.
Eric van Glabbeek