c#向word中添加图片的时候出现错误System.Runtime.InteropServices.COMException: 这不是有效文件名

    技术2022-07-11  115

    参考 https://www.cnblogs.com/louby/p/6427626.html https://www.cnblogs.com/fuyun2000/archive/2013/06/16/3139141.html 用C#向word里面添加照片 执行到这一行代码

    Selection sel = app.Selection;

    或者

    Microsoft.Office.Interop.Word.InlineShape shape = _app.ActiveDocument.InlineShapes.AddPicture(photofile, ref linkToFile, ref saveWithDocument, ref range);

    均出现错误 System.Runtime.InteropServices.COMException: 这不是有效文件名。 经过多次尝试,发现是因为打开的word文件的路径包括了中文字符。。再一次验证了:用中文名给文件夹命名就是吃饱了撑的,给自己找事情做。

    Processed: 0.013, SQL: 9