How to run commandline argument in asp.net application

Hi Expert,

i am bit confused about to converting a swf file to .flv format dynamically, though i got a tool that convert it but it needs a command line argument to be executed in the server to do this.I am bit confused how i ll do this because i have developed the application in asp.net with c#, is there any possible chance to do this means when the user will submit the request for conversion that time the swf2videocmd xxx.swf -out myvideo.avi -f avi -vcodec bgr24 -vbr 5000000 -acodec mp3 -asr 44100 -abr 128000 -ac 2 will be executed in the server to get the desired out put.I need some solution to do this.


Thanks
Tanayya
tanu80Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kelvin McDanielSr. Developer/ConsultantCommented:
This is an older post, but still effective. It also contains an example for making an async call.

http://www.codeproject.com/KB/cs/Execute_Command_in_CSharp.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tanu80Author Commented:
Hi ,

thanks for the suggestion but bit worry to use the code because the exe is present in the C:\Program Files\Moyea\SWF to Video SDK\swf2videocmd and how i ll use it.

I am using below set of code


 protected void Page_Load(object sender, EventArgs e)
    {
       

        ExecuteCommandAsync("swf2videocmd d:\\tanayya\\theme.swf -out d:\\tanayya\\Mona.avi -f avi -vcodec bgr24 -vbr 5000000 -acodec mp3 -asr 44100 -abr 128000 -ac 2");
        //ExecuteCommandAsync("d:\\tanayya\\theme.swf ");
     

    }

    public void ExecuteCommandSync(object command)
    {
        try
        {
            // create the ProcessStartInfo using "cmd" as the program to be run,
            // and "/c " as the parameters.
            // Incidentally, /c tells cmd that we want it to execute the command that follows,
            // and then exit.
            System.Diagnostics.ProcessStartInfo procStartInfo =
                new System.Diagnostics.ProcessStartInfo("SWF to Video SDK Command Prompt.exe", " " + command);

            // The following commands are needed to redirect the standard output.
            // This means that it will be redirected to the Process.StandardOutput StreamReader.
            procStartInfo.RedirectStandardOutput = true;
            procStartInfo.UseShellExecute = false;
            // Do not create the black window.
            procStartInfo.CreateNoWindow = true;
            // Now we create a process, assign its ProcessStartInfo and start it
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            proc.StartInfo = procStartInfo;
            proc.Start();
            // Get the output into a string
            string result = proc.StandardOutput.ReadToEnd();
            // Display the command output.
            Response.Write(result);
        }
        catch (Exception objException)
        {
            // Log the exception
        }
    }
    public void ExecuteCommandAsync(string command)
{
   try
   {
    //Asynchronously start the Thread to process the Execute command request.
    Thread objThread = new Thread(new ParameterizedThreadStart(ExecuteCommandSync));
    //Make the thread as background thread.
    objThread.IsBackground = true;
    //Set the Priority of the thread.
    objThread.Priority = ThreadPriority.AboveNormal;
    //Start the thread.
    objThread.Start(command);
   }
   catch (ThreadStartException objException)
   {
    // Log the exception
   }
   catch (ThreadAbortException objException)
   {
    // Log the exception
   }
   catch (Exception objException)
   {
    // Log the exception
   }
}

I am not getting the out put.
0
Kelvin McDanielSr. Developer/ConsultantCommented:
A few things I see...

1. Make sure you're disposing of things properly. I'm not sure but I don't think you are... And I'm not in front of a computer so I can't verify that. Put it this way; in the code you've provided, any object that has a Close() or Dispose() method needs to had that/those methods called when you are finished using those objects.

2. Make sure that you are putting quotes around any paths that you're passing to the OS. It needs those to know that it should treat those strings as full paths.

3. I'd suggest letting the window be visible until you're sure your code is working. Also, add a line where the window won't disappear until you dismiss it. If I'm not mistaken that's Console.ReadKey().

Try those and see how it goes.

2.  
0
FarWestCommented:
I think it is better to isolate the whole conversion call from the ASP.NET process
1) make a table in your database that will hold the queue of requests with details and status,
2) Make a windows service that monitor that table and excute conversions (you can use workitems for multible threads) 3) your ASP.NEt will insert on that table , and will check when the user refresh (or automatic refresh) is done on that page if he has completed conversion, or even show the progress

this way asp.net process will not be chuncked with sub-threads
0
tanu80Author Commented:
thanks for the solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.