c# - perl.exe cannot be called by ProcessStartInfo -


I am trying to work with the following code so that I can call a Perl script from my C # program. I am using Visual Studio 2008 on XP Service Pack 3.

myProcess = new process (); ProcessStartInfo myProcessStartInfo = New ProcessStartInfo ("perl.exe"); MyProcessStartInfo.Arguments = @ "C: \ Documents and Settings \ test_perl.pl"; MyProcessStartInfo.UseShellExecute = false; MyProcessStartInfo.RedirectStandardOutput = True; MyProcessStartInfo.WindowStyle = Process WindowStyle.Hidden; MyProcessStartInfo.CreateNoWindow = True; MyProcess.StartInfo = myProcessStartInfo; MyProcess.Start (); String output = myProcess.StandardOutput.ReadToEnd (); MessageBox.Show (Production); MyProcess.WaitForExit ();

I confirm test_perl.pl and if I change perl.exe to notepad.exe, then works above the code. But if I use perl.exe, the message box is empty.

It is not understandable why this is wrong. If you know, please help me.

thanks

Unless the path perl.exe is empty on the command line Are you Try quoting the path:

  myProcessStartInfo.Arguments = @ "" "C: \ Documents and Settings \ test_perl.pl" "";  

Since the command line arguments are delimited with spaces, the application (perl.exe, in this case) will see three arguments if the file path is not cited. :

  1. C: \ document
  2. and
  3. settings \ test_perl.pl

"C: \ Documents" will try to open. It does not exist, of course. The solution is to cite those path paths, in which empty space (or all file paths to keep compatible).

You mention that Notepad.XA fixes the recorded file pathlessly. It's likely that this Notepad is smarter than the average bear, and is merging its arguments.

And verify that a path exists on that path, of course. This is actually a slightly unusual path; Generally, you will see the user file in something like C: \ documents and settings \ myusername \ Documents \ file.ext , or something like that.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -