我想在asp.net的服务器端运行一个批处理文件,我使用以下命令来执行批处理文件。它在调试模式下运行时工作正常,但是当我托管 URL 并调用批处理文件时,它不工作。
受保护的无效Button1_Click(对象发送者,EventArgs e){
try
{
if (FileUpload1.FileName == "")
{
Label1.Visible = true;
Label1.Text = "Browse Respective text file";
return;
}
if ((File.Exists(Server.MapPath("~/DND_BASE/" + FileUpload1.FileName))) == true)
{
Label1.Visible = true;
Label1.Text = "File Name already Uploaded";
return;
}
else
{
string DestFilepath = @"D:\124_SMS_DATA\124_SMS_Base\"+FileUpload1.FileName;
string SrcFilepath = Server.MapPath("~/DND_BASE/") + FileUpload1.FileName;
FileUpload1.SaveAs(System.IO.Path.Combine(Server.MapPath("~/DND_BASE/"), FileUpload1.FileName));
if (File.Exists(DestFilepath))
{
File.Delete(DestFilepath);
}
File.Move(SrcFilepath, DestFilepath);
Label5.Visible = true;
Label5.Text = "File Uploaded Successfully You can download file after 5 Mins";
string path = Server.MapPath(".") + "\\test.bat";
System.Diagnostics.Process.Start(path);
}
}
catch(Exception ex)
{
err = new ErrorHandler();
err.WriteToErrorLog(ex.Message.ToString());
}
}