Click here to Skip to main content
15,039,149 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hello Please Help me i am getting error
her is my code

C#
public string RunExternalExe(string filename, string arguments = null)
       {
           var process = new Process();

           process.StartInfo.FileName = filename;
           if (!string.IsNullOrEmpty(arguments))
           {
               process.StartInfo.Arguments = arguments;
           }

           process.StartInfo.CreateNoWindow = true;
           process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
           process.StartInfo.UseShellExecute = false;

           process.StartInfo.RedirectStandardError = true;
           process.StartInfo.RedirectStandardOutput = true;
           var stdOutput = new StringBuilder();
           process.OutputDataReceived += (sender, args) => stdOutput.Append(args.Data);

           string stdError = null;
           try
           {
              // process.Start("rtmpdump.exe");
               System.Diagnostics.Process.Start("rtmpdump", filename);
              // Process.Start(filename);
               process.BeginOutputReadLine();
               stdError = process.StandardError.ReadToEnd();
               process.WaitForExit();
           }
           catch (Exception e)
           {
               throw new Exception("OS error while executing " + Format(filename, arguments) + ": " + e.Message, e);
           }

           if (process.ExitCode == 0 || process.ExitCode == 2)
           {
               string yes = "yes";

               return yes;
           }
           else
           {


               return "no";
           }
       }

       private static string Format(string filename, string arguments)
       {
           return "'" + filename +
               ((string.IsNullOrEmpty(arguments)) ? string.Empty : " " + arguments) +
               "'";
       }
Posted
Updated 28-Jul-20 22:52pm
v2

have solved m problem


C#
string currentLocation = AppDomain.CurrentDomain.BaseDirectory;
           string[] s=  currentLocation.Split('b');
           string final = s[0] +"b"+ s[1] +"b"+ s[2];

          
         string rtmpDump = Path.Combine(final, "Tool\\Rtmpdump\\rtmpdump.exe");
   
v2
Hi Lakhan,

The error occurs in System.Diagnostics.Process.Start("rtmpdump", filename); line?
If it so then the file you are trying to access from the path is not valid as the error itself is self descriptive.....

Suggestion: Check for the file in the path manually through explorer.
I think c# code wont blame you unnecessarily ;-)

Hope this helps you a bit.

Regards,
RK
   
Comments
[no name] 14-Nov-13 2:23am
   
yes you are right but how to get path this my current path how to get this path using code.....
C:\Users\Om\Documents\Visual Studio 2010\Projects\Multimedia URL Probe 1.0\Multimedia URL Probe 1.0\Tool\Rtmpdump\rtmpdump.exe
Two things:
1) check that "rtmpdump" is installed, available, and on the system path: open a command prompt and type "rtmpdump" and press ENTER. Does it run? I suspect not...
2) why do you crest a Process instance, and then totally ignore it?
   
Comments
[no name] 14-Nov-13 2:24am
   
thanks.
yes you are right please read my above comment?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900