小编Mur*_*aev的帖子

尝试在 C# .NET 中使用 Process.Start 打开文本文件时出错

我正在使用 .NET 6.0 在 C# 中开发控制台应用程序。我有一个用于存储条目的 Journal 类和一个用于将日记条目保存到文件的 Persistence 类。当我尝试使用打开保存的文本文件时遇到错误Process.Start。错误信息如下:

Unhandled exception. System.ComponentModel.Win32Exception (193): An error occurred trying to start process 'c:\temp\journal.txt' with working directory 'C:\Mentorship\Design Patterns\bin\Debug\net6.0'. The specified executable is not a valid application for this OS platform.
Run Code Online (Sandbox Code Playgroud)

我的代码的相关部分:

Unhandled exception. System.ComponentModel.Win32Exception (193): An error occurred trying to start process 'c:\temp\journal.txt' with working directory 'C:\Mentorship\Design Patterns\bin\Debug\net6.0'. The specified executable is not a valid application for this OS platform.
Run Code Online (Sandbox Code Playgroud)

我期望此代码使用默认的关联程序打开保存的文本文件。但是,我收到了上面提到的错误。如何解决此问题并Process.Start在 .NET 6.0 中成功打开文本文件?

.net c# design-patterns

1
推荐指数
1
解决办法
1172
查看次数

标签 统计

.net ×1

c# ×1

design-patterns ×1