使用C#.net将byte []转换为字符串 [英] converting byte[] into string using C# .net

查看:97
本文介绍了使用C#.net将byte []转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨Frds,
我将Word文档作为数据类型varbinary(MAX)上传到SQL SERVER中...
我需要显示该文档中的文本...通过从SQL SERVER提取...
在文本框中显示文本...我正在获取byte [],但无法转换为文本...

由Suresh

Hi Frds,
I uploaded Word Document into SQL SERVER as Datatype varbinary(MAX)...
I need to display the text which is in that document...by fetching from SQL SERVER...
Display Text in Textbox...I am getting byte[] , but not able to convert into text...

by Suresh

推荐答案

在您的特定实例中可能无济于事,但是...

byte []转换为字符串:
It may not help in your specific instance, but...

byte[] to string:
byte[] bytes = ...
string s = System.Text.Encoding.ASCII.GetString(bytes);

之所以可能无济于事,是因为Word文件不仅是文本,还有很多(我的意思是很多)额外的信息,这些信息描述了如何显示文本以及其他内容.作为字符串得到的内容很可能无法直接显示为文本.

The reason it may not help is that a Word file is not just text - there is a lot (and I do mean a lot) of extra information which describes how to display the text, among other stuff. What you get as a string will very probably not be directly displayable as text.


这篇关于使用C#.net将byte []转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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