MemoryStream.Position或MemoryStream.Seek不起作用(Silverlight) [英] MemoryStream.Position or MemoryStream.Seek does not work (Silverlight)

查看:213
本文介绍了MemoryStream.Position或MemoryStream.Seek不起作用(Silverlight)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Silverlight应用程序中有一条记忆流.我必须将此内存流复制到文件流对象.如果我打电话:

I have a memorystream in 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);

是否两次显示相同的非零数字?我很难相信MemoryStream就是这样.

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

顺便说一句,使用MemoryStream复制比手动复制所有内容更简单的方法是调用

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

这篇关于MemoryStream.Position或MemoryStream.Seek不起作用(Silverlight)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆