本文介绍了抛出“系统找不到指定的文件"的Process.Start()方法.将数据加载到数据库时出错.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

am尝试使用.BAT,.CTL和.DAT文件将某些记录加载到Dtabase中.下面的代码我创建了,它无法正常工作,并且当控件进入process.Start()方法时抛出以下错误消息.

实际上,Bat,ctl和Data字段是同一目录中的实例.我确定这些文件中的数据和代码没有问题.

am trying to load some records into Dtabase by using .BAT, .CTL and .DAT fiels. Below code i have created and it is not working and throwing following error message when control comes process.Start() method.

Actually, Bat, ctl and Data fiels are exixts in same directory. I am sure there is no issue with the data and code in these files.

如果我们找到解决方案,那将非常有帮助.

It would be very helpful if we get solution.

错误:系统找不到指定的文件

ERROR: The system cannot find the file specified

Stact跟踪:  在System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)处
  在System.Diagnostics.Process.Start()处
  在ConsoleApplication3.Program.createHeader1(字符串hdr1Path,字符串环境)

Stact trace:    at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at ConsoleApplication3.Program.createHeader1(String hdr1Path, String environment)

代码:

CODE:

private 静态 void createHeader1( 字符串 hdr1Path, 字符串 环境)

privatestaticvoid createHeader1(string hdr1Path, string environment)

        {

       {

            尝试

           try

            {

           {

                ProcessStartInfo ProcessInfo;

               ProcessStartInfo ProcessInfo;

                处理 p;

               Process p;

                ProcessInfo = ProcessStartInfo ();

               ProcessInfo = newProcessStartInfo();

                ProcessInfo.FileName = "qaheader1_1600.bat"" ;

               ProcessInfo.FileName = "qaheader1_1600.bat";

                ProcessInfo.WindowStyle = ProcessWindowStyle .隐藏;

               ProcessInfo.WindowStyle = ProcessWindowStyle.Hidden;

              ProcessInfo.WorkingDirectory = Path .GetDirectoryName(hdr1Path);

               ProcessInfo.WorkingDirectory = Path.GetDirectoryName(hdr1Path);

                ProcessInfo.UseShellExecute = ;

               ProcessInfo.UseShellExecute = false;

                p = 处理 ();

               p = newProcess();

                p.StartInfo = ProcessInfo;

               p.StartInfo = ProcessInfo;

                p.Start();

               p.Start();

                p.WaitForExit();

               p.WaitForExit();

                p.Close();

               p.Close();

           }

           }

            捕获 ( 例如)

           catch (Exception ex)

            {

           {

          

          

             }

           }

  }

       }

推荐答案

请改用以下代码.我已经通过了测试,效果很好.

Please use the following code instead. I've tested on my side, it works fine.

  ProcessInfo.FileName=hdr1Path+@"\Clean.bat";

顺便说一句,根据您的代码,我还没有看到在任何地方使用参数环境,可以将其删除.

By the way, based on your code, I haven't seen any where use parameter environment, you can remove it.

最诚挚的问候,

克里斯汀


这篇关于抛出“系统找不到指定的文件"的Process.Start()方法.将数据加载到数据库时出错.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 23:05