繁体   English   中英

System.ComponentModel.Win32Exception (0x80004005): 系统找不到指定的文件

[英]System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified

我正在尝试使用以下代码打开两个文件之一中的文档:

try
{
    startInfo.FileName = "WINWORD.EXE";
}
catch(Win32Exception)
{
    startInfo.FileName = "TMViewer.exe";
}

我的笔记本电脑上没有 MS Word,所以我希望 catch 会触发它在 Word 查看器程序中打开,但我收到了这条消息:

System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified

我已更新注册表以获取运行TMViewer.exe的快捷方式,它实际上可以在我的另一台 PC 上运行,但如果我尝试在没有安装 Word 的笔记本电脑上运行它,我会不断收到此错误。

当您Start()进程时抛出异常,而不是在您设置该选项时。

但是,您无需执行任何操作。
相反,只需将FileName设置为您要打开的文档,Windows 就会自动在用户的关联程序中打开它。

暂无
暂无

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

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