温馨提示:本文翻译自stackoverflow.com,查看原文请点击:c# - How to open a textfile with the default editor in .NET Core
.net .net-core c# file

c# - 如何在.NET Core中使用默认编辑器打开文本文件

发布于 2020-04-10 16:56:03

在.NET Framework中,我可以简单地做,但是在Process.Start(filename);.NET Core中,我会遇到此异常:

System.ComponentModel.Win32Exception:'指定的可执行文件不是此OS平台的有效应用程序。

如何开始testfile.txt使用默认应用程序?谢谢!

查看更多

提问者
BDevGW
被浏览
123
Ismael Padilla 2020-02-02 00:24

像这样打开它:

new Process
{
    StartInfo = new ProcessStartInfo(filename)
    {
        UseShellExecute = true
    }
}.Start();