Hi Guys I was wondering if anyone could assist me by telling me / correcting my code as to where I am going wrong.

I'm trying to simply excute flvmeta.exe, and pass the parameters:

"flvmeta input.flv output.flv"

when I do this manually it works fine, however when I build and try and run this .exe it does not run the: "flvmeta input.flv output.flv" I know that it is finding the flvmeta.exe, however for some reason there is an issue with my startInfo.Arguments. Could someone please help me out, I'm loosing my hair.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        LaunchCommandLineApp();
    }

    /// <summary>
    /// Launch the legacy application with some options set.
    /// </summary>
    static void LaunchCommandLineApp()
    {
        // For the example
        const string inputFLV = "input.flv";
        const string outputFLV = "output.flv";

        // Use ProcessStartInfo class
        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.CreateNoWindow = false;
        startInfo.UseShellExecute = false;
        startInfo.FileName = "flvmeta.exe";
        startInfo.WindowStyle = ProcessWindowStyle.Hidden;
        startInfo.Arguments = "flvmeta " + inputFLV + " " + outputFLV + "";

        try
        {
            // Start the process with the info we specified.
            // Call WaitForExit and then the using statement will close.
            using (Process exeProcess = Process.Start(startInfo))
            {
                Console.Write(startInfo.Arguments);
                exeProcess.WaitForExit();
            }
        }
        catch
        {
            // Log error.
        }
    }
}

Hi Guys I was wondering if anyone could assist me by telling me / correcting my code as to where I am going wrong.

I'm trying to simply excute flvmeta.exe, and pass the parameters:

"flvmeta input.flv output.flv"

when I do this manually it works fine, however when I build and try and run this .exe it does not run the: "flvmeta input.flv output.flv" I know that it is finding the flvmeta.exe, however for some reason there is an issue with my startInfo.Arguments. Could someone please help me out, I'm loosing my hair.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        LaunchCommandLineApp();
    }

    /// <summary>
    /// Launch the legacy application with some options set.
    /// </summary>
    static void LaunchCommandLineApp()
    {
        // For the example
        const string inputFLV = "input.flv";
        const string outputFLV = "output.flv";

        // Use ProcessStartInfo class
        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.CreateNoWindow = false;
        startInfo.UseShellExecute = false;
        startInfo.FileName = "flvmeta.exe";
        startInfo.WindowStyle = ProcessWindowStyle.Hidden;
        startInfo.Arguments = "flvmeta " + inputFLV + " " + outputFLV + "";

        try
        {
            // Start the process with the info we specified.
            // Call WaitForExit and then the using statement will close.
            using (Process exeProcess = Process.Start(startInfo))
            {
                Console.Write(startInfo.Arguments);
                exeProcess.WaitForExit();
            }
        }
        catch
        {
            // Log error.
        }
    }
}

You don't need to pass in the name of your exe into the ProcessStartInfo.Arguments property. Try initializing the ProcessStartInfo with the exe: ProcessStartInfo startInfo = new ProcessStartInfo("flvmeta.exe"); Also see: Process.Start & ProcessStartInfo.Arguments...

As a side note, the process you are launching is probably in the same current working directory as the program itself. So if your program is in C:\Program Files\MyCoolApp, when you execute "flvmeta input.flv output.flv" it might think those files are in the same folder. You may need to set the "WorkingDirectory" property of ProcessStartInfo first.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.