必须在c#中使用FileStream和StreamReader读取单词Document [英] Have to read a word Document using FileStream and StreamReader in c#

查看:123
本文介绍了必须在c#中使用FileStream和StreamReader读取单词Document的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有一个FilePath。使用FilePath我必须从路径中读取Word或PDF文件,并且必须像这样返回File()。



我试过



I have a FilePath now. Using FilePath i have to read the Word or PDF file from the path and have to return File() like this.

I tried

FileStream fStream = new FileStream(filepath, FileMode.Open, FileAccess.Read);
                  StreamReader sReader = new StreamReader(fStream);
                  strReader = sReader.ReadToEnd();
                  sReader.Close();





但它不起作用,它给特殊字符喜欢? |等等..

请帮助



提前感谢



But its not working, its giving the Special Characters like ? | etc..
Please help

thanks in advance

推荐答案

It而是取决于你要对内容做什么。但是,您需要了解Word文档和PDF文件都是特殊格式,您不能通过这种方式阅读它们。您需要使用其中一个免费库(OpenOffice,iTextSharp等)。或者,您可以将Microsoft Office Word Interop用于Word文档,或者从Adobe学习PDF格式规范,并编写自己的。
It rather depends what you are trying to do with the content. However, you need to understand that both Word documents and PDF files are in special formats that you cannot easily understand by reading them this way. You need to use one of the free libraries (OpenOffice, iTextSharp etc). Alternatively you can use the Microsoft Office Word Interop for word documents, or study the PDF format specification from Adobe, and write your own.


这篇关于必须在c#中使用FileStream和StreamReader读取单词Document的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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