ASP.NET Error System.ComponentModel.Win32Exception:'系统找不到指定的文件'

时间:2017-04-27 17:56:02

标签: c# asp.net button

我到处寻找这个答案。这是在调试期间单击网页上的button1时。我尝试了几个目录,都没有运气。有什么建议。我绝对肯定这不是路径名称的问题。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;

public partial class Simulators : System.Web.UI.Page
{ 


    private System.Diagnostics.Process myBatProcess;

    //private void Form1_Load(object sender, EventArgs e)
    //{
    //    this.button1.Click += new EventHandler(button1_Click);
    //}

    public void button1_Click(object sender, EventArgs e)
    {
        System.Diagnostics.ProcessStartInfo myBatStartInfo = new 
System.Diagnostics.ProcessStartInfo();
        myBatStartInfo.UseShellExecute = true;  // needed since bat is not an executable
        myBatStartInfo.FileName = @"C:\BATs\TrainingProZ_10_EC_autoscale.bat";

        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Web;
        using System.Web.UI;
        using System.Web.UI.WebControls;
        using System.Diagnostics;

public partial class Simulators : System.Web.UI.Page
    {


        private System.Diagnostics.Process myBatProcess;

        //private void Form1_Load(object sender, EventArgs e)
        //{
        //    this.button1.Click += new EventHandler(button1_Click);
        //}

        public void button1_Click(object sender, EventArgs e)
        {
            System.Diagnostics.ProcessStartInfo myBatStartInfo = new System.Diagnostics.ProcessStartInfo();
            myBatStartInfo.UseShellExecute = true;  // needed since bat is not an executable
            myBatStartInfo.FileName = @"C:\Users\175020\Desktop\ProZ_10_EC_autoscale.bat";

            myBatProcess = System.Diagnostics.Process.Start(myBatStartInfo);
        }

        protected void Button2_Click(object sender, EventArgs e)
        {

        }
    }
    myBatProcess = System.Diagnostics.Process.Start(myBatStartInfo);
    }

    protected void Button2_Click(object sender, EventArgs e)
    {

    }
}

1 个答案:

答案 0 :(得分:0)

要使其工作,应使用正斜杠来定义FileName:

myBatStartInfo.FileName = "C://BATs//TrainingProZ_10_EC_autoscale.bat";