【问题标题】:I want to run any .exe. The program is processing but not opening我想运行任何 .exe。程序正在处理但未打开
【发布时间】:2020-06-09 10:15:20
【问题描述】:

我想运行任何 .exe。程序正在处理但未打开。它假装打开,但没有打开。 图片:https://prnt.sc/swgg23

private void Button1_Click(object sender, EventArgs e)
        {
            Process process = new Process();
            process.StartInfo.FileName = DosyaYolu;
            process.Start();

        }

        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog file = new OpenFileDialog();
            file.Filter = "Exe files (*.exe)|*.exe|All files (*.*)|*.*";
            file.FilterIndex = 1;
            file.RestoreDirectory = true;
            file.CheckFileExists = false;
            file.Title = "Exe Dosyası Seçiniz..";

            if (file.ShowDialog() == DialogResult.OK)
            {
                // dosya seçildi ise
                DosyaYolu = file.FileName;
                DosyaAdi = file.SafeFileName;
            }
            label1.Text = DosyaYolu;
        }

【问题讨论】:

  • 你说的假装是什么意思?
  • 我的意思是“好像在工作”。
  • Process process = Process.Start("filename"); 运行它或将ProcessStartInfo 设置为process.Start(new ProcessStartInfo("filename"));

标签: c#


【解决方案1】:

我喜欢你的代码,它也对我有用,让我们试试吧,它会奏效的 :) (我在 Console(.NET Core) App 下尝试,而不是 .NET Framework。也许这很重要。)

        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.CreateNoWindow = false;
        startInfo.UseShellExecute = false;
        startInfo.FileName = @"C:\appname.exe";//Your appname
        Process.Start(startInfo);

【讨论】:

  • Ithink 也适用于 Form 应用程序,仅适用于 .NET Core prnt.sc/swh7xm
  • 我以前从未使用过它。我会调查并尝试。
猜你喜欢
  • 1970-01-01
  • 2015-02-23
  • 2016-09-09
  • 2011-09-28
  • 1970-01-01
  • 2015-07-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多