[英]find the installation path (with exe file there but not currently running) in win 7 from C# VS2013
From C# VS2013, I would like to get the whole path of an application that has been indtalled on win 7. 从C#VS2013,我想了解Win 7上安装的应用程序的完整路径。
The post with 7 methods at: 该帖子提供7种方法,网址为:
http://stackoverflow.com/questions/6041332/best-way-to-get-application-folder-path
cannot help me because I do Not need the path of the current running application. 无法帮助我,因为我不需要当前正在运行的应用程序的路径。
I need the path of an application that has been installed (but currently not running ). 我需要已安装(但当前未运行 )的应用程序的路径。
I have tried 我努力了
string [] allfiles = Directory.GetFiles(path, "*", SearchOption.AllDirectories)
at 在
http://stackoverflow.com/questions/23736343/recursive-search-for-files-in-root-directory-and-subfolders
But got: 但是得到了:
Additional information: Access to the path 'C:\Program Files\MSSomeApp\DATA' is denied.
My C# code: 我的C#代码:
FileInfo executableFileInfo = new FileInfo("MyApplication.exe"); // It has been installed on win 7.
string executableDirectoryName = executableFileInfo.DirectoryName;
This just returned my current VS2013 working directory. 这只是返回了我当前的VS2013工作目录。 But, actually, "MyApplication.exe" was installed at C:\\MyPath.
但是,实际上,“ MyApplication.exe”已安装在C:\\ MyPath中。
I need to get the full file path C:\\MyPath\\, where all libs and exe files (of MyApplication) are there. 我需要获取完整的文件路径C:\\ MyPath \\,所有MyApplication的libs和exe文件都在其中。
Any suggestions ? 有什么建议么 ? thanks
谢谢
Well You can use something like: 好吧,您可以使用类似:
string[] paths =
System.IO.Directory.GetFiles(System.Environment.SpecialFolder.ProgramFiles,
"MyApplication.exe", System.IO.SearchOption.AllDirectories);
This will look the Program Files Folder and all its Sub Folders for the file named MyApplication.exe and will return the full path of all of matches 这将在Program Files文件夹及其所有子文件夹中查找名为MyApplication.exe的文件,并将返回所有匹配项的完整路径
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.