C# 如何确定打开文件的完整路径
我正在编写一个 Excel 插件,我希望能够确定当前打开的 Excel 文件的完整路径。将其作为字符串获取的命令是什么?
谢谢你!
I am programming an excel add in, and I want to be able to determine the full path of the current excel file open. What would the command be to get this as a string?
Thank You!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您需要以某种方式获得一个
Workbook
示例。我的例子很明显,因为我已经知道我的文件在哪里,但是如果您从某个地方将Workbook
传递给您,您可以使用相同的属性。现在,您可以使用
FullName
属性来获取文件名和所有前面的路径,或者简单地使用“Name”来获取文件名:openedWorkbook.FullName
First of all you need to somehow get a
Workbook
exemplar. My example would be obvious, because I've already know where is my file, but if you gettingWorkbook
passed to you from somewhere you can use the same property.Now you can use
FullName
property to get name of file and all preceding path, or simply "Name" to get only filename:openedWorkbook.FullName