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路径下就好了。 --------------------编程问答-------------------- 应该是路径问题。试试:
--------------------编程问答-------------------- 把 id.StartInfo.WorkingDirectory 设为 BAT 所在目录也可以
string fullPath = Path.GetFullPath(@".\VStorm\GetStatus_BPDVM.bat");
string directory = Path.GetDirectoryName(fullPath);
ie.StartInfo.FileName = fullPath;
ie.StartInfo.WorkingDirectory = directory; //<----
补充:.NET技术 , C#