Share via


SPFile.OpenBinaryStream method

Opens the file as a stream.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Public Function OpenBinaryStream As Stream
'Usage
Dim instance As SPFile
Dim returnValue As Stream

returnValue = instance.OpenBinaryStream()
public Stream OpenBinaryStream()

Return value

Type: System.IO.Stream
An object that represents the file.

Remarks

Under specific circumstances, an error can occur that prompts the following message "The path specified is being used in a substitute" (HRESULT: 0x80070092). This error occurs when you create an instance of SPFile by using the SPWeb.GetFile(Guid) method, passing in the GUID of the desired file. If you then call the OpenBinaryStream method, the parameter reference is incorrectly a null reference (Nothing in Visual Basic) and causes the error described.

To work around this problem, use the GetFile(String) version of the GetFile method and instead of a GUID, pass in the URL to the file.

See also

Reference

SPFile class

SPFile members

OpenBinaryStream overload

Microsoft.SharePoint namespace