0
我想打开/阅读我的docx文档。到目前为止,一切正常,但如果文件名包含“_”,“”,“ - ”,则会出现一些例外情况,但由于以下原因导致出现异常:COMException尝试打开特定的文字文件时
其他信息:对不起,找到你的文件。它可能被移动,重命名或删除了吗?
什么我到目前为止做:
string path = "C:/Users/Hans/Rep";
foreach (string file in Directory.EnumerateFiles(path, "*.docx"))
{
{
//Open the doc File
var fileInfo = new FileInfo(file);
if (!fileInfo.Name.StartsWith("~$"))
{
var wordApplication = new Microsoft.Office.Interop.Word.Application();
var document = wordApplication.Documents.Open(file);
//Set paper Size
document.PageSetup.PaperSize = WdPaperSize.wdPaperA4;
崩溃试图打开文件时出现。是否需要设置一些特定的参数/参数?!
尝试通过双击它们打开该文件,一旦我得到相同的异常,同时调查我知道文件已损坏。 –
@SilverShadow没有没有损坏,我可以打开他们 –
试图从另一个驱动器打开他们 –