(1) First reference DocX.dll in the project
(2)
<form action="~/Controller/File" method="post" enctype="multipart/form-data">
<input type="file" />
<input type="submit" value="提交" />
</form>
(3)
[HttpPost]
public ActionResult File(HttpPostedFileBase Word)
{
// save the current text to
Word.SaveAs(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Folder Name\\") + "File Name" + "." + "Extension");
//Read the word in the specified path
Novacode.DocX docx = DocX.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "folder name\\") + "file name" + "." + "extension");//The path to save the word
// Traverse the word text
foreach (var item in docx.Paragraphs)
{
// loop through all text in docx
item //The first data
}
}
The content is purely hand-typed, if it helps, please give a like