如何将argotic.feed.save结果写入内存流?
我想将 Argotic 写入内存流,然后将其作为字符串返回到另一个函数。 这就是我写的:
Stream st = new MemoryStream();
Feed.Save(st); //argotic Save method has the ability to write into Stream
StreamReader sr = new StreamReader(st);
return sr.ReadToEnd();
但我只得到一个空字符串,尽管 st.length 显示了正确的长度,但其中没有字符:-?
我该如何解决这个问题?
问候。
I want to write Argotic to memorystream and then return it as a string to another function.
and this is what I've written :
Stream st = new MemoryStream();
Feed.Save(st); //argotic Save method has the ability to write into Stream
StreamReader sr = new StreamReader(st);
return sr.ReadToEnd();
but I only got an empty string although the st.length shows me the correct length but there no character in it :-?
how Can I solve this problem?
regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
保存后,将流的位置重置为 0 以从头开始读取。否则,您将从当前位置读取,这是流的末尾,因为它刚刚被写入:
Reset the position of the stream to 0 to read from the beginning, after the save. Otherwise you'll read from the current position, which is the end of the stream since it has just been written to: