.Net Core 2.0 Process.Start throws “The specified executable is not a valid application for this OS platform”

前端 未结 5 536
走了就别回头了
走了就别回头了 2020-12-03 16:34

I need to let a .reg file and a .msi file execute automatically using whatever executables these two file types associated with on user\'s Windows.

.NET Core 2.0 Pro

5条回答
  •  余生分开走
    2020-12-03 17:11

    use this to open a file

    new ProcessStartInfo(@"C:\Temp\1.txt").StartProcess();
    

    need this extension method

    public static class UT
    {
        public static Process StartProcess(this ProcessStartInfo psi, bool useShellExecute = true)
        {
            psi.UseShellExecute = useShellExecute;
            return Process.Start(psi);
        }
    }
    

提交回复
热议问题