解析Excel的路径 [英] Resolve path of Excel
问题描述
其实我想提出以下问题:
Actually I intended to ask the following question:
对于关键在于可执行
在定义的目录%PATH%
,怎么能
我发现在这些目录中
它被发现的?
For an executable that lies in a directory defined in
%PATH%
, how can I find out in which of these directory it is found?
因为我需要使用Process.Run(...)C#运行Excel,只是表示创先争优工作正常:WINDOWS似乎知道哪里可以找到它。不过,我需要提供相应的工作目录了。
because I need to run Excel from C# using Process.Run(...), and just indicating "Excel" works fine: Windows seems to know where to find it. However I need to provide the appropriate working directory, too.
但与此同时我发现,微软的Office是不是即使在%PATH%时,Windows显然解决它以另一种方式。
But in the meantime I found out that Microsoft Office is not even in the %PATH%, Windows apparently resolves it in another way.
所以,我怎么能使用或模仿从Windows此功能来获取包含Excel中的目录?
So how could I use or mimic this functionality from Windows to get the directory containing excel?
更新:此外鲁埃尔的建议,有一个直的方式实现这一目标?我知道,Windows是能够解析以某种方式的路径,所以我想重新使用这个功能,如果可能的。
Update: Besides the suggestion of Ruel, is there a straighter way to achieve this? I know that Windows is able to resolve the path in some way, so I'd like to reuse this functionality if possible.
你知道吗?
推荐答案
从注册表中读取它: HKLM \ SOFTWARE \微软\办公室\(版本)\ EXCEL \ InstallRoot
为版本
也可以是10.0 11.0等,您可以通过检查,如果有一个子项检测到它 Excel中
在里面
Fetch it from the registry: HKLM\SOFTWARE\Microsoft\Office\(VERSION)\Excel\InstallRoot
for the VERSION
it can be 10.0 11.0 etc. You can detect it by checking if there's a subkey Excel
in it.
这篇关于解析Excel的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!