渲染文件流的内容 [英] Rendering the contents of file stream

查看:58
本文介绍了渲染文件流的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件流对象,并且想要渲染该文件流对象的内容以将其打开.最好的方法是什么?

I have a file Stream object and want to render the content of that file Stream object opening it. What's the best approach to do that?

推荐答案

这取决于您要呈现它的方式或流中包含的内容.

It depends how you want to render it or what the stream contains.

您是说只想显示原始字节吗?还是Stream包含纯文本或图像或其他内容?

Do you mean you just want to display the raw bytes? Or does the Stream contain plain text or an image or something else?

如果其中包含文本,则可以使用StreamReader.只需创建一个,然后将Stream传递给构造函数,然后使用ReadToEnd()将这些行读出到绑定到合适的控件(例如TextBlock)的字符串属性中即可.

If it contains text you could use a StreamReader. Simply create one, passing in the Stream to the constructor, then read out the lines using ReadToEnd() into a string property bound to a suitable control such as a TextBlock.

如果其中包含图像,则可以使用Image类.使用Image.FromStream创建一个,然后再次将其绑定到合适的控件.

If it contains an image you could use the Image class. Use the Image.FromStream to create one and, again, bind it to a suitable control.


这篇关于渲染文件流的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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