c# - Process.Start() 不提示应用程序选择
问题描述
当双击具有未知文件类型的文件时,windows 会弹出一个窗口,允许我选择要使用哪个应用程序打开文件。
我正在尝试使用以下代码在我的应用程序中打开文件,直到最近我才得到相同的结果
var startInfo = new ProcessStartInfo(document.DownloadPath);
startInfo.UseShellExecute = true;
Process.Start(startInfo);
当我转到应用程序的其他部分时,我不知道它何时停止工作,但现在尝试打开扩展名未知的文件时出现以下错误。
System.ComponentModel.Win32Exception (1155): No application is associated with the specified file for this operation.
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
使用我的应用程序打开或实际双击文件时,如何获得相同的体验?
解决方案
推荐阅读
- bash - grep 并过滤掉文件中的值
- r - 如何按日期分组并将循环输出保存到新变量中?
- kubernetes - 新手 - 更改了 yaml - 如何用相同的方式更新 k8s 集群
- javascript - 即使使用了一个组,SignalR 也会向所有人广播
- python - 只有当它们高于某些值时,如何对列值进行数学运算,否则在熊猫中将其设置为 1?
- python - 如何使用 html 文件在 django 中显示 ChoiceField?
- react-native - 使用 expo 在 react-native 中打开 PDF 文件
- android - 用户未点击软键盘的确认按钮时获取 EditText 内容
- php - 条件 SQL 查询 [VueJS]
- java - Android 软键盘adjustPan 进一步向上调整视图