file.exists,但没有路径只知道应用程序的名称 [英] file.exists, but with no path only knowing the name of an app
本文介绍了file.exists,但没有路径只知道应用程序的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试运行Word.exe,但如果用户在不同的磁盘或分区上安装了办公室,则可以找到该应用。不要写代码中的完整路径。
我试过这样:
I am trying to run Word.exe, but if a user installed office on different disk or partition, to find the app. Not to write the full path in the code.
I tried like this:
if (File.Exists(Word.exe;))
{
Process.Start("Word.exe");
}
但没有运气。
but no luck.
推荐答案
尝试:
Try:
Process.Start("WinWord.exe");
而不是
Instead of
Process.Start("Word.exe");
您可以删除文件存在检查 - 它只会查看应用程序当前文件夹,因此它永远不会找到无论如何,单词。
You can remove the file exists check - it will only look in the application current folder, so it should never find Word anyway.
这篇关于file.exists,但没有路径只知道应用程序的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文