引入 Aspose.Words
public void ConvertToHtml(string wordPath, string savaPath){try{Aspose.Words.Document doc = new Aspose.Words.Document(wordPath);if (doc == null){throw new Exception("Word文件无效或者Word文件被加密!");}if (savaPath.Trim().Length == 0){savaPath= Path.GetDirectoryName(wordPath);}if (!Directory.Exists(savaPath)){Directory.CreateDirectory(savaPath);}string wordName = Path.GetFileNameWithoutExtension(wordPath);Aspose.Words.Saving.HtmlSaveOptions htmlSaveOptions = new Aspose.Words.Saving.HtmlSaveOptions(Aspose.Words.SaveFormat.Html);string wordPath = Path.Combine(savaPath, wordName ) + "_001.html";doc.Save(wordPath , htmlSaveOptions);}catch (Exception ex){throw new FriendlyException("word的格式或版本不适用");}}