开发者

MemoryStream.Position or MemoryStream.Seek does not work (Silverlight)

开发者 https://www.devze.com 2022-12-14 10:24 出处:网络
I have a memorystream i开发者_运维技巧n a silverlight app. I have to copy this memorystream to a filestream object. If I call:

I have a memorystream i开发者_运维技巧n a silverlight app. I have to copy this memorystream to a filestream object. If I call:

memoryStream.Position = 0;
memoryStream.Seek(0,SeekOrigin.Begin);

It does not work, I debug the application, check the properties of the memorystream, and the position still points to the end of the file. Any clues?


Is it possible that another of your properties is being triggered in the debugger, and reading through the stream?

Rather than using the debugger, what happens if you log (or show on a message box):

Log("Position = " + stream.Position);
stream.Position = 0;
Log("Position = " + stream.Position);

Does that show the same non-zero number twice? I find it hard to believe that MemoryStream is that broken.

Btw, a simpler way of using MemoryStream for copying than manually copying everything is to call WriteTo with the FileStream as an argument.

0

精彩评论

暂无评论...
验证码 换一张
取 消