Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I can using streamreader to read a all doc files in My document folder and write all file content in a single doc file(output.doc). I using below coding. But it may read doc file content in encoded format. It dont not paste doc file.

VB
Dim mydirpath As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
       Dim txtlist As String() = Directory.GetFiles(mydirpath, "*.doc")
       Dim strfile As New StringBuilder
       Dim txtname As String
       For Each txtname In txtlist
           Using sr As New StreamReader(txtname)
               strfile.AppendLine(txtname.ToString())
               strfile.Append(sr.ReadToEnd())
               strfile.AppendLine()
           End Using
       Next
       Using outfile As New StreamWriter(mydirpath + "\output.doc")
           outfile.Write(strfile.ToString())
       End Using
Posted
Updated 11-Nov-11 5:43am
v2

You cannot read word doc files with a streamreader. You need to have word installed on the computer and use the Interop Assemblies[^].
 
Share this answer
 
I already explained this to you; why do you need to repost the same question?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900