【问题标题】:ASP.NET Error System.ComponentModel.Win32Exception: 'The system cannot find the file specified'ASP.NET 错误 System.ComponentModel.Win32Exception: '系统找不到指定的文件'
【发布时间】:2017-04-28 13:17:01
【问题描述】:

我到处寻找这个答案。这是在调试期间单击网页上的 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)
    {

    }
}

【问题讨论】:

  • 您是否尝试使用 myBatStartInfo.WorkingDirectory = @"C:\BATs" 然后只使用 myBatStartInfo.FileName="TrainingProZ_10_EC_autoscale.bat" 设置工作目录?

标签: c# asp.net button


【解决方案1】:

要使其正常工作,文件名应使用正斜杠定义,如下所示:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-24
    • 1970-01-01
    • 1970-01-01
    • 2018-09-26
    相关资源
    最近更新 更多