Questions tagged [getbuffer]
6 questions
45
votes
7 answers
When is GetBuffer() on MemoryStream ever useful?
I've known that GetBuffer() on a MemoryStream in C#/.NET has to be used with care, because, as the docs describe here, there can be unused bytes at the end, so you have to be sure to look only at the first MemoryStream.Length bytes in the…

aggieNick02
- 2,557
- 2
- 23
- 36
24
votes
4 answers
Why does MemoryStream.GetBuffer() always throw?
The following code will always throw
UnuthorizedAccessException (MemoryStream's internal buffer cannot be accessed.)
byte[] buf1 = { 2, 3, 5, 7, 11 };
var ms = new MemoryStream(buf1);
byte[] buf2 = ms.GetBuffer(); // exception will be thrown…

I. J. Kennedy
- 24,725
- 16
- 62
- 87
17
votes
4 answers
What if I don't call ReleaseBuffer after GetBuffer?
From CString to char*, ReleaseBuffer() must be used after GetBuffer(). But why? What will happen if I don't use ReleaseBuffer() after GetBuffer()?
Can somebody show me an example? Thanks.

Landy
- 379
- 1
- 4
- 10
5
votes
1 answer
CString::GetBuffer() example
I am trying to understand the GetBuffer() function. Looks like it returns you the pointer to the CString, which is confirmed in msdn GetBuffer(). However, I don't understand the example shown in the msdn GetBuffer().
LPTSTR p = s.GetBuffer( 10…

HoKy22
- 4,057
- 8
- 33
- 54
1
vote
1 answer
Can I getBuffer after image.close?
I camera2 api, I save continuously image to Image[] and when want to capture picture, I call image.getPlanes()[0].getBuffer but app crashed and show error:
Image is already close.
How can I getBuffer after image.close ?
Thank you!

nguyencobap
- 39
- 4
1
vote
1 answer
Getting bad content in trailing section exception, when parsing xml produced by C# client in a GAEJ app
I am trying to POST a potentially large chunk of xml from a C# client to a GAEJ app, and then parse it into a DOM document.
I've managed to get the documentbuilder to parse the xml by parsing the request data into a string and then trimming it, as…

tempy
- 1,567
- 2
- 18
- 28