1、引用包Aspose.Words
2、接口中使用:
List formFiles = new();
foreach (IFormFile formFile in formCollection.Files)
{
if (formFile.ContentType == "application/msword")
{
Stream fs = formFile.OpenReadStream();
var doc = new Aspose.Words.Document(fs);
Stream stream = new MemoryStream();
doc.Save(stream, Aspose.Words.SaveFormat.Docx);
FormFile formFiled = new(stream, 0, stream.Length, null, formFile.FileName.Replace(".doc", ".docx"))
{
Headers = new HeaderDictionary()
};
formFiled.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
formFiles.Add(formFiled);
}
}