简体   繁体   English

如何从C#获取Word文档的文件名?

[英]How can I get the filename of a Word document from C#?

I'm working on a MS Word AddIn (VSTO). 我正在研究MS Word AddIn(VSTO)。 The idea is that I work on a Word document and I send it somewhere. 我的想法是我在Word文档上工作并将其发送到某个地方。

I have all the code I need except one thing: is there a way I can get the filename of the Word document I'm working on? 除了一件事,我有我需要的所有代码:有没有办法可以获得我正在处理的Word文档的文件名? (assuming that is already saved) (假设已经保存)

this.FullName property in the code-behind .cs file should give you the entire path of the current doc. 代码隐藏.cs文件中的this.FullName属性应该为您提供当前文档的完整路径。

Here's the exact query in my QuickWatch window. 这是我的QuickWatch窗口中的确切查询。

((Microsoft.Office.Tools.Word.Document)(this)).FullName

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM