c# - 没有应用程序与指定的文件异常关联

标签 c# exception-handling notepad process.start win32exception

UnhandledException: System.ComponentModel.Win32Exception: 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)
   at System.Diagnostics.Process.Start(String fileName)

大家好,

尝试使用 Process.Start 打开 .csv 文件时,我正在测试的一台机器上出现以下异常。我认为发生这种情况是因为在此框中没有为 .csv 文件设置文件关联。

那么你会如何避免这种情况呢?

强制 Process.Start 在记事本中打开? - 理想情况下,它应该在 excel 中打开,但是如果 excel 在该计算机上不存在怎么办?

谢谢

最佳答案

如果设置 ProcessStartInfo.ErrorDialog = true,则用户将收到标准 Windows 对话框提示:参见 here

关于c# - 没有应用程序与指定的文件异常关联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2634198/

相关文章:

python - 在 Windows 记事本的 Python 中创建 UTF-16 换行符

c# - 如何使用 NumericUpDown 计算文本框值的总数?

exception-handling - Doctrine2异常(exception)列表

java - 使用异常处理 Java REST API 的应用程序和业务故障场景

java - 异常处理标准建议

c++ - 发出 textChanged() 信号时获取 QTextEdit 更改

powershell - 了解如何在记事本中使用反引号(MS)

c# - 用于在另一个字符串中查找部分字符串的正则表达式

c# - 关闭密码表单 c#

c# - 将一个窗口放在另一个窗口前面