从.doc读取数据并写入文本文件 [英] Read data from .doc and write in to text file

查看:70
本文介绍了从.doc读取数据并写入文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从.doc文件中读取文本"",其中包含一些电子邮件地址,例如"abc@gmail.com",并以相同格式写入.text文件.

为此,我有以下代码..将数据读入二进制文件并在转换为文本后以文本形式写入文本文件,但这没有给我正确的响应.
它有什么问题,请指导.....


昏暗的FILE_NAME作为字符串= C:\ Users \ Owner \ Documents \ test.Doc


昏暗的StringReader()作为字符串

将finStream1变暗为新的IO.FileStream(FILE_NAME,IO.FileMode.Open,IO.FileAccess.Read)
将fStream1设置为新的IO.FileStream(& quot; C:\ Users \ prakash \ Desktop \ EmailTEst.text,IO.FileMode.Create,IO.FileAccess.Write)

作为新IO.BinaryReader(finStream1,System.Text.Encoding.UTF8)的昏暗
Dim bw作为新的IO.StreamWriter(fStream1)
昏暗的字节读取为字节
br.BaseStream.Seek(3,IO.SeekOrigin.Begin)
Dim strstring As String ="
而br.ReadByte& gt; 0
byteRead = br.ReadByte
strstring = strstring和Char.ConvertFromUtf32(byteRead)
bw.Write(strstring)
结束时
br.Close()
bw.Close()

感谢您提出的改善我问题的建议.

I want to read text from .doc file ''''Which is contain some email address like ''abc@gmail.com'' and write into .text file in same format .

for this I had code as following.. to read data into binary and write into text file as text after convert into text , but it is not giving me correct response.
What is wrong with it please guide........


Dim FILE_NAME As String = C:\Users\Owner\Documents\test.Doc


Dim StringReader() As String

Dim finStream1 As New IO.FileStream(FILE_NAME, IO.FileMode.Open, IO.FileAccess.Read)
Dim fStream1 As New IO.FileStream("C:\Users\prakash\Desktop\EmailTEst.text, IO.FileMode.Create, IO.FileAccess.Write)

Dim br As New IO.BinaryReader(finStream1, System.Text.Encoding.UTF8)
Dim bw As New IO.StreamWriter(fStream1)
Dim byteRead As Byte
br.BaseStream.Seek(3, IO.SeekOrigin.Begin)
Dim strstring As String = ""
While br.ReadByte > 0
byteRead = br.ReadByte
strstring = strstring & Char.ConvertFromUtf32(byteRead)
bw.Write(strstring)
End While
br.Close()
bw.Close()

Thanks for your advice to improve my question.

推荐答案

不会-文档文件不会以可读的形式存储

您将必须使用单词自动化-例如此处的使用VB的单词自动化.NET-第I部分 [ ^ ]
it won''t - doc files aren''t stored in a readable form

You''ll have to use word automation - example here Word Automation using VB.NET - Part I[^]


这篇关于从.doc读取数据并写入文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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