共用方式為


SPFile.OpenBinaryStream Method

Opens the file as a stream.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

Syntax

'Declaration
<SubsetCallableExcludeMemberAttribute(SubsetCallableExcludeMemberType.MarshalByRefObject)> _
Public Function OpenBinaryStream As Stream
'Usage
Dim instance As SPFile
Dim returnValue As Stream

returnValue = instance.OpenBinaryStream()
[SubsetCallableExcludeMemberAttribute(SubsetCallableExcludeMemberType.MarshalByRefObject)]
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