问题描述
我想从.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.
推荐答案
这篇关于从.doc读取数据并写入文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!