This document is archived and information here might be outdated.  Recommended version.


IByteSwapStreamIO.Read Method (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference (System)  

IByteSwapStreamIO.Read Method

Perform a read byte swapping to the native format.

[Visual Basic .NET]
Public Sub Read ( _
    ByVal dataType As esriByteSwapDataType, _
    ByVal pv As IntPtr, _
    ByVal cb As Integer, _
    ByRef pcbRead As Integer _
)
[C#]
public void Read (
    esriByteSwapDataType dataType,
    IntPtr pv,
    uint cb,
    ref uint pcbRead
);
[C++]
HRESULT Read(
  esriByteSwapDataType dataType,
  pv* pv,
  Unsigned long cb,
  Unsigned long* pcbRead
);
[C++]

Parameters dataType [in]
dataType is a parameter of type esriByteSwapDataType pv [out] pv is a parameter of type cb [in] cb is a parameter of type Unsigned long pcbRead [out] pcbRead is a parameter of type Unsigned long

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

DataType [in]

  User specified type of the data to perform swapping on.

pv [out]

  A pointer to the buffer which the stream data is read into.

cb [in]

  The number of bytes of data to read from the stream object.

pcbRead [out]

  A pointer to a ULONG variable that receives the actual number of bytes 

  read from the stream object. It could be set to NULL. In this case,

  the Read method does not provide the number of bytes read.

 

The Read method reads requested (in cb variable) number of bytes from the stream object into memory, starting at the current seek pointer, and swaps it into the native format. The actual number of bytes read can be less than it was requested if the end of the stream is reached during the read operation or an error can occur if nothing was read from the stream object.

 

VC++ example:

  // Open the file and set it to be the stream object

  IBlobStreamPtr ipBlobStream(CLSID_FileStream);
  IFilePtr ipFile(ipBlobStream);
  ipFile->Open(L"C:\\fileIn", esriReadOnly);
  IStreamPtr ipStream(ipFile);
  IByteSwapStreamIOPtr ipByteSwapStreamIO (CLSID_ByteSwapStreamIO);   
  ipByteSwapStreamIO->putref_Stream(ipStream); 


  // Get the size of the stream 

  unsigned long size;
  ipBlobStream->get_Size(&size);


  // Read and swap stream
  BYTE pv[14];
  ULONG pcbRead;
  ipByteSwapStreamIO->Read(esriBSDTBYTE, &pv, size, &pcbRead);

See Also

IByteSwapStreamIO Interface