There is a code that reads data from a Word document:
public void getWordTokens(string wordFilePath) { Object fileName = wordFilePath; Word.Application app = new Word.Application(); var _tokenList = new List<string>(); try { app.Documents.Open(ref fileName); Word.Document document = app.ActiveDocument; Console.WriteLine("Words count - " + document.Words.Count); Console.WriteLine("Document name - " + document.Name); StringBuilder res = new StringBuilder(); for (int i = 1; i < document.Words.Count; i++) { res.Append(document.Words[i].Text); } Console.WriteLine(res.ToString()); } finally { app.Quit(); } } There are no questions in the work, on very small Word-files it works relatively quickly (in fact, not, but tolerant). But on large files - a nightmare begins - it works for a long time.
How can this whole thing be improved?
PS when the emergency program is closed, the Word process does not close, although it is finnaly surrounded, is this the norm?
finally. The process is killed in a straightforward way. - VladD