Quote:
C# read a word file in the fastest way
Your problem is not reading the file, your problem is building the result.
for (int i = 0; i < docs.Paragraphs.Count; i++)
{
totaltext += docs.Paragraphs[i + 1].Range.Text.ToString();
}
The cost of building
totaltext
is
O(n)= n² with n the number of paragraph.
Instaed of building
totaltext
and then write it to result file, you can directly write each paragraph directly to resulting file.
An alternative is to use a string builder.