0
下面的代碼基本上是我逐字檢查一個文檔並分開正確的文檔。我工作,但速度太慢,我必須等待超過10分鐘的4萬字。當我打開相同的文件時,幾秒鐘後會檢查它。我究竟做錯了什麼?Word Interop按字拼寫檢查文檔太慢
var application = new Application();
application.Visible = false;
Document document = application.Documents.Open("C:\\Users\\hrzafer\\Desktop\\spellcheck.docx");
// Loop through all words in the document.
int count = document.Words.Count;
IList<string> corrects = new List<string>();
for (int i = 1; i <= count; i++)
{
if (document.Words[i].SpellingErrors.Count == 0)
{
string text = document.Words[i].Text;
corrects.Add(text);
}
}
File.WriteAllLines("corrects.txt", corrects);
application.Quit();