当前位置:编程学习 > C#/ASP.NET >>

c#调用bat文件的问题

这个bat双击运行是没有问题的,
但是用C# 调用的话,会显示图中的错误,如图


C# code:
System.Diagnostics.Process ie = new System.Diagnostics.Process();
ie.StartInfo.FileName = @".\VStorm\GetStatus_BPDVM.bat";
ie.Start();
ie.WaitForExit(); --------------------编程问答-------------------- 除 --------------------编程问答-------------------- 把.exe文件copy到debug路径下就好了。 --------------------编程问答-------------------- 应该是路径问题。试试:

string fullPath = Path.GetFullPath(@".\VStorm\GetStatus_BPDVM.bat");
string directory = Path.GetDirectoryName(fullPath);

ie.StartInfo.FileName = fullPath;
ie.StartInfo.WorkingDirectory = directory;  //<----
--------------------编程问答-------------------- 把 id.StartInfo.WorkingDirectory 设为 BAT 所在目录也可以
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,