首页 > 编程语言 >C# process =An error occurred trying to start process with working directory The specified executabl

C# process =An error occurred trying to start process with working directory The specified executabl

时间:2024-09-09 22:15:55浏览次数:9  
标签:Process executable ProcessStartInfo process System application Diagnostics start

 using System.Diagnostics;
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
string path= @"..\..\..\Image";
string fullPath = System.IO.Path.GetFullPath(path);
var imgsList = System.IO.Directory.GetFiles(fullPath);
foreach (var img in imgsList)
{
    Console.WriteLine(img);
    ProcessStartInfo startInfo = new ProcessStartInfo(img);    
    startInfo.WindowStyle = ProcessWindowStyle.Maximized;
    //startInfo.UseShellExecute = true;
    Process.Start(startInfo);
}



System.ComponentModel.Win32Exception
  HResult=0x80004005
  Message=An error occurred trying to start process 'D:\C\ConsoleApp69\Image\1.jpg' with working directory 'D:\C\ConsoleApp69\bin\Debug\net8.0'. The specified executable is not a valid application for this OS platform.
  Source=System.Diagnostics.Process
  StackTrace:
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) in /_/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs:line 611
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) in /_/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs:line 1350
   at Program.<Main>$(String[] args) in D:\C\ConsoleApp69\Program.cs:line 13



https://stackoverflow.com/questions/46808315/net-core-2-0-process-start-throws-the-specified-executable-is-not-a-valid-appl

 

 

Copy solution from 

https://stackoverflow.com/questions/46808315/net-core-2-0-process-start-throws-the-specified-executable-is-not-a-valid-appl

 

 

//set the UseShellExecute property of ProcessStartInfo to true
using System.Diagnostics;
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
string path= @"..\..\..\Image";
string fullPath = System.IO.Path.GetFullPath(path);
var imgsList = System.IO.Directory.GetFiles(fullPath);
foreach (var img in imgsList.Take(5))
{
    Console.WriteLine(img);
    ProcessStartInfo startInfo = new ProcessStartInfo(img);    
    startInfo.WindowStyle = ProcessWindowStyle.Maximized;
    startInfo.UseShellExecute = true;
    Process.Start(startInfo);
}

 

标签:Process,executable,ProcessStartInfo,process,System,application,Diagnostics,start
From: https://www.cnblogs.com/Fred1987/p/18405453

相关文章

  • Applications of UDTL to Intelligent Fault Diagnosis: A Survey and Comparative St
    文章目录摘要一、引言二、背景和定义A.UDTL定义B.基于UDTL的IFD分类C.基于UDTL的IFD动机D.主干结构三、LABEL-CONSISTENTUDTLA.基于网络的UDTLB.基于实例化的UDTLC.基于映射的UDTLD.基于对抗性的IFD四.LABEL-INCONSISTENTUDTLA.PartialUDTLB.OpenSetUDTLC.Uni......
  • A COMPREHENSIVE SURVEY ON EVALUATING LARGE LANGUAGE MODEL APPLICATIONS IN THE ME
    本文是LLM系列文章,针对《ACOMPREHENSIVESURVEYONEVALUATINGLARGELANGUAGEMODELAPPLICATIONSINTHEMEDICALINDUSTRY》的翻译。关于评估医疗行业中大型语言模型应用程序的综合调查摘要1引言和背景2综述的分类和结构3医学领域LLM应用评估的现状4挑战......
  • Designing Data-Intensive Applications
    《DesigningData-IntensiveApplications》是一本深入探讨数据密集型应用设计的书籍,由MartinKleppmann撰写。以下是对这本书的详细概述:书籍简介:作者信息:MartinKleppmann是一位在分布式系统领域的研究员,曾在LinkedIn和Rapportive等互联网公司工作,参与大规模数据基础设......
  • 手动添加Spring Boot的配置文件application.properties
      本文介绍在IntelliJIDEA软件中,为SpringBoot项目添加配置文件的操作方法。  最近,在IntelliJIDEA软件中新创建了一个SpringBoot项目,是通过如下图所示的方法直接新建的。  但是,随后发现这样创建的SpringBoot项目没有配置文件。如下图所示,其他的基本项目架构都是存在的......
  • Go - Web Application 10
    CreatingaunittestInGo,it’sstandardpracticetowriteyourtestsin*_test.gofileswhichlivedirectly alongsidethecodethatyou’retesting.So,inthiscase,thefirstthingthatwe’regoingtodo iscreateanewcmd/web/template_test.gofilet......
  • Design Patterns for Cloud Native Applications
    研究背景研究问题:本书旨在解决如何构建云原生应用的问题。云原生应用具有成本节约和可扩展性的优势,但其开发和部署面临诸多挑战。研究难点:云原生应用的复杂性在于如何在动态环境中设计和开发可扩展、可靠、可管理和可观测的应用。相关工作:本书参考了现有的架构原则和实......
  • Go - Web Application 9
    UsingrequestcontextAtthemomentourlogicforauthenticatingauserconsistsofsimplycheckingwhethera "authenticatedUserID"valueexistsintheirsessiondata,likeso:func(app*application)isAuthenticated(r*http.Request)bool{......
  • 谈谈Spring中的BeanPostProcessor接口(转)
    原文:谈谈Spring中的BeanPostProcessor接口作者:特务依昂 一.前言  这几天正在复习Spring的相关内容,在了解bean的生命周期的时候,发现其中涉及到一个特殊的接口——BeanPostProcessor接口。由于网上没有找到比较好的博客,所有最后花了好几个小时,通过Spring的官方文档对它做了......
  • python测试开发基础---multiprocessing.Pool
    1.基础概念多进程编程:Python中的multiprocessing模块允许你使用多个进程并行执行任务,这可以提高程序的性能,尤其是在需要大量计算的情况下。Pool类是一个常用工具,可以帮助你更轻松地管理多个进程。进程池:进程池是一个包含多个工作进程的池子,用来处理多个任务。你可以将任......
  • python 多进程的 Process 和 Queue 的使用
    QuestionfrommultiprocessingimportProcess,Queue解释下这个多进程AnswerfrommultiprocessingimportProcess,Queue是用于多进程处理的模块。详细解释多进程:multiprocessing模块提供了类似于threading模块的API,但它使用的是进程而不是线程。每个进程都有自己的......