Hi All,
I'm trying to use System.Runtime.InteropServices.ComTypes.IStream from C#, but I'm having some trouble. According to MSDN, the C# definition looks like this:
void Read(
byte[] pv,
int cb,
IntPtr pcbRead
)
Basically, I can read data from the stream, but the above "pcbRead" value is always "0" (even though the byte array contains my data). Doing some reading, it seems as if the pcbRead argument is somewhat tricky to set up properly (though I'm fairly 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 the read, though "buffer" seems to contain valid data.