2014-01-24 108 views

回答

1

通過互操作方法等

但該網頁上的幾個備選方案,如ofc tool看一看在here,絕對有可能。

C#Snippet from that page。

static void Main(string[] args) 
{ 
    Word._Application application = new Word.Application(); 
    object fileformat = Word.WdSaveFormat.wdFormatXMLDocument; 
    DirectoryInfo directory = new DirectoryInfo(@"c:\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; 
}