using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.IO.Packaging;
using System.Xml;
namespace ReadDocx
{
class Program
{
static void Main(string[] args)
{
string path = "a.docx";
using (Package package = Package.Open(path))
{
Uri docxUri = new Uri("/word/document.xml", UriKind.Relative);
PackagePart docxPart = package.GetPart(docxUri);
XmlDocument docxXmlDocument = new XmlDocument();
docxXmlDocument.Load(docxPart.GetStream());
Console.WriteLine(docxXmlDocument.InnerText.ToString());
}
}
}
}
记得要导入WindowsBase引用!!!