I am trying to use System.Runtime.InteropServices.ComTypes.IStream from C #, but I am having problems. According to MSDN, the C # definition is as follows:
void Read(
byte[] pv,
int cb,
IntPtr pcbRead
)
Basically, I can read data from the stream, but the above value of "pcbRead" is always "0" (although the byte array contains my data). While doing some reading, it seems that the pcbRead argument is a little harder to set up correctly (although I'm pretty new to C #).
Anyway, my code basically looks like this:
myPtr = (IntPtr)0;
int buffSize = 8192;
byte[] buffer = new byte[buffSize];
while (true)
{
strm.Read(buffer, buffSize, myPtr);
fs.Write(buffer, 0, myPtr.ToInt32());
if (myPtr.ToInt32() < buffSize) break;
}
Again, the problem is that "myPtr" still contains "0" after reading, although the "buffer" seems to contain valid data.
source
share