나는 또한 동일한 문제에 직면했다. .doc을 .docx로 변환하려면 Microsoft.Office.Interop.Word 라이브러리를 사용할 수 있습니다. 그것은 나를 위해 작동합니다. 여기에 코드가 있습니다.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Word = Microsoft.Office.Interop.Word;
using System.Reflection;
using System.IO;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Word._Application application = new Word.Application();
object fileformat = Word.WdSaveFormat.wdFormatXMLDocument;
DirectoryInfo directory = new DirectoryInfo(@"D:\abc");
foreach (FileInfo file in directory.GetFiles("*.doc", SearchOption.AllDirectories))
{
if (file.Extension.ToLower() == ".doc")
{
object filename = file.FullName;
object newfilename = file.FullName.ToLower().Replace(".doc", ".docx");
Word._Document document = application.Documents.Open(filename);
document.Convert();
document.SaveAs(newfilename, fileformat);
document.Close();
document = null;
}
}
application.Quit();
application = null;
}
}
}
그것은 또한 당신을 위해 작동합니다
..
참조 스레드 - http://stackoverflow.com/questions/1803576/convert-word-doc-file-to-docx-on-a-server -without-word – adatapost
자세한 참조 스레드 - http://stackoverflow.com/questions/2405417/automation-how-to-automate-transforming-doc-to-docx – Holf