I want to read the content of a NotesStream object (COM reference) without using the file system. Thus my intension was to transfer the content into a .NET byte array. My examples are in VB.net because we needed late binding at that time.
The only way I managed to do it is by reading the stream byte by byte (assuming the Position in the stream was set to 0
beforehand):
Dim streamSize As Long = CInt(notesStream.Bytes)
Dim buffer(streamSizes - 1) As Byte
For i = 0 To (streamSize - 1)
buffer(i) = notesStream.read(1)(0)
Next
This is very very slow compared to using the filesystem (notesStream.Open()
).
The other solutions I found all gave me errors, like this 2 examples:
buffer = notesStream.Read(streamSize)
-> error: the object of type "System.Byte[ * ]" cannot be converted to type "System.Byte[]" / Unable To Cast Object Of Type "System.Byte[ * ]" To Type "System.Byte[]"
(without the additional space character between the brackets and the asterisk, but otherwise it wouldn't have benn displayed correctly in this post)
Array.Copy(notesStream.Read(), 0, buffer, 0, streamSize)
-> error: Source array was not long enough. Check srcIndex and length, and the array's lower bounds.